@cloudlet/toast 1.4.0-rc.1 → 1.5.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 +181 -0
- package/README.md +30 -5
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +19 -15
- package/dist/agent.js.map +1 -1
- package/dist/center-react.d.ts +286 -0
- package/dist/center-react.d.ts.map +1 -0
- package/dist/center-react.js +2 -0
- package/dist/center.d.ts +3 -0
- package/dist/center.d.ts.map +1 -0
- package/dist/center.js +1 -0
- package/dist/core/agent-port.d.ts +2 -0
- package/dist/core/agent-port.d.ts.map +1 -1
- package/dist/core/agent-port.js +3 -0
- package/dist/core/agent-port.js.map +1 -1
- package/dist/react/card.d.ts +4 -0
- package/dist/react/card.d.ts.map +1 -1
- package/dist/react/card.js +3 -8
- package/dist/react/card.js.map +1 -1
- package/dist/react/center-backdrop.d.ts +69 -0
- package/dist/react/center-backdrop.d.ts.map +1 -0
- package/dist/react/center-backdrop.js +81 -0
- package/dist/react/center-backdrop.js.map +1 -0
- package/dist/react/center-clear.d.ts +16 -0
- package/dist/react/center-clear.d.ts.map +1 -0
- package/dist/react/center-clear.js +24 -0
- package/dist/react/center-clear.js.map +1 -0
- package/dist/react/center-gestures.d.ts +47 -0
- package/dist/react/center-gestures.d.ts.map +1 -0
- package/dist/react/center-gestures.js +74 -0
- package/dist/react/center-gestures.js.map +1 -0
- package/dist/react/center-motion.d.ts +174 -0
- package/dist/react/center-motion.d.ts.map +1 -0
- package/dist/react/center-motion.js +344 -0
- package/dist/react/center-motion.js.map +1 -0
- package/dist/react/center.d.ts +15 -0
- package/dist/react/center.d.ts.map +1 -0
- package/dist/react/center.js +1287 -0
- package/dist/react/center.js.map +1 -0
- package/dist/react/focus.d.ts +7 -0
- package/dist/react/focus.d.ts.map +1 -0
- package/dist/react/focus.js +14 -0
- package/dist/react/focus.js.map +1 -0
- package/dist/react/gestures.d.ts +33 -2
- package/dist/react/gestures.d.ts.map +1 -1
- package/dist/react/gestures.js +181 -149
- package/dist/react/gestures.js.map +1 -1
- package/dist/react/host.d.ts.map +1 -1
- package/dist/react/host.js +287 -283
- package/dist/react/host.js.map +1 -1
- package/dist/react/motion.d.ts +18 -11
- package/dist/react/motion.d.ts.map +1 -1
- package/dist/react/motion.js +6 -3
- package/dist/react/motion.js.map +1 -1
- package/dist/react/reduced.d.ts +24 -0
- package/dist/react/reduced.d.ts.map +1 -0
- package/dist/react/reduced.js +35 -0
- package/dist/react/reduced.js.map +1 -0
- package/dist/react/zoom.d.ts +12 -0
- package/dist/react/zoom.d.ts.map +1 -0
- package/dist/react/zoom.js +21 -0
- package/dist/react/zoom.js.map +1 -0
- package/dist/react.d.ts +4 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +3 -2
- package/src/agent.ts +11 -6
- package/src/center-react.ts +300 -0
- package/src/center.ts +27 -0
- package/src/core/agent-port.ts +3 -0
- package/src/react/card.tsx +5 -6
- package/src/react/center-backdrop.tsx +151 -0
- package/src/react/center-clear.ts +56 -0
- package/src/react/center-gestures.ts +143 -0
- package/src/react/center-motion.ts +504 -0
- package/src/react/center.tsx +1557 -0
- package/src/react/focus.ts +18 -0
- package/src/react/gestures.ts +127 -37
- package/src/react/host.tsx +17 -5
- package/src/react/motion.ts +16 -9
- package/src/react/reduced.ts +52 -0
- package/src/react/zoom.ts +26 -0
- package/src/react.ts +4 -0
package/dist/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","names":["freeze","EMPTY","quote","TOASTER_VERBS","NOTIFICATION_VERBS","VERBS","STRICTNESS","DONE","GONE","STALE","UNAVAILABLE","FORM_REJECTED","FORM_FAILED","texts","action","step","name","names","item","field","limit","label","messages","message","NO_AUTHORS","NOT_AVAILABLE","refuse","allowed","outcome","result","done","words","toasterAgent","options","port","createToasterPort","controller","refs","issued","refOf","ref","handle","known","islandRef","seeded","listeners","stop","source","entries","targets","snapshot","reading","state","byHandle","island","count","found","notifications","entry","notification","plan","current","mounted","holdsDraft","target","fillPlan","command","pressPlan","form","operation","value","candidate","permission","started","approved","signal","ended","describe","checked","check","verdict","run","context","subject","summon","collect","commit","live","changes","touched","push","reason","by","event","events","next","authors","previous","own","failure","each","error","errors","labels","sentence","description","content","progress","actionEntry","ready","may","shown","common"],"sources":["../src/agent.ts"],"sourcesContent":["import type { CloudletController } from './contracts/controller.js';\nimport type { ChangeSource } from './contracts/events.js';\nimport type { NotificationHandle } from './contracts/identity.js';\nimport type { FormErrors } from './contracts/internal.js';\nimport type { CommandAction, FormAction, FormFieldKind, FormInputMode, NotificationKind, Priority } from './contracts/notifications.js';\nimport type { CancellationSignal, OperationStatus } from './contracts/operations.js';\nimport type { NotificationLocation, NotificationSnapshot, PauseReason } from './contracts/snapshots.js';\nimport { createToasterPort, type FormReading, type PortCommit, type ToasterReading } from './core/agent-port.js';\n\n// The Toaster's side of the agent bridge. Its protocol types are declared here structurally:\n// this package never imports the bridge package, not even its types.\n\n/**\n * One record of an agent snapshot, as the bridge reads it.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentEntryShape = {\n readonly ref: string;\n readonly component: string;\n readonly actions: readonly string[];\n readonly [key: string]: unknown;\n};\n\n/**\n * A cancellation signal as the bridge hands it out; an `AbortSignal` at runtime.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentSignalShape {\n readonly aborted: boolean;\n readonly reason: unknown;\n readonly throwIfAborted: () => void;\n readonly addEventListener: (type: 'abort', listener: () => void, options?: { readonly once?: boolean }) => void;\n readonly removeEventListener: (type: 'abort', listener: () => void) => void;\n}\n\n/**\n * A value a step may return to the agent.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentValueShape = string | number | boolean | null | readonly AgentValueShape[] | { readonly [key: string]: AgentValueShape };\n\n/**\n * What a step may do: on its own, with approval, or never.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentPermissionShape = 'allow' | 'confirm' | 'deny';\n\n/**\n * A step as the bridge hands it to a component.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentStepCallShape {\n readonly ref: string;\n readonly action: string;\n readonly args: readonly unknown[];\n}\n\n/**\n * How a person names what a step acts on, for the bridge's messages.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentStepNamesShape {\n readonly target: string;\n readonly within?: string;\n}\n\n/**\n * A component's answer to the bridge's `check`.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentStepCheckShape =\n | { readonly available: true; readonly permission: AgentPermissionShape; readonly names?: AgentStepNamesShape }\n | { readonly available: false; readonly message?: string };\n\n/**\n * What the bridge's `run` receives besides the step.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentRunContextShape {\n readonly signal: AgentSignalShape;\n readonly approved: 'allow' | 'confirm';\n}\n\n/**\n * A component's answer to the bridge's `run`.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentRunOutcomeShape =\n | { readonly status: 'done'; readonly result?: AgentValueShape; readonly gone?: boolean }\n | { readonly status: 'failed'; readonly message: string }\n | { readonly status: 'unavailable'; readonly message?: string }\n | { readonly status: 'stale' };\n\n/**\n * A component's answer to the bridge's `summon`.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentSummonOutcomeShape = boolean | { readonly reached: boolean; readonly note: string };\n\n/**\n * One change a component reports to the bridge's subscribers: what changed on which record and who\n * changed it.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentChangeShape {\n readonly ref: string;\n readonly component: string;\n readonly label?: string;\n readonly key: string;\n readonly value: AgentValueShape;\n readonly previous: AgentValueShape;\n readonly reason?: string;\n readonly source: 'user' | 'agent' | 'app' | 'system';\n}\n\n/**\n * What a component's verbs do, by kind of record: each verb with a line or two for an agent.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentVerbsShape {\n readonly [component: string]: { readonly [verb: string]: string };\n}\n\n/**\n * What a component hands to the bridge's `connect`. `check` and `run` come together, `summon` is\n * optional, and a read-only component leaves all three out.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentComponentShape<Entry extends AgentEntryShape = AgentEntryShape> {\n readonly protocol: 1;\n readonly name: string;\n snapshot(): readonly Entry[];\n subscribe(listener: (changes?: readonly AgentChangeShape[]) => void): () => void;\n readonly check?: (step: AgentStepCallShape) => AgentStepCheckShape;\n readonly run?: (step: AgentStepCallShape, context: AgentRunContextShape) => AgentRunOutcomeShape | PromiseLike<AgentRunOutcomeShape>;\n readonly summon?: (step: AgentStepCallShape) => AgentSummonOutcomeShape;\n readonly verbs?: AgentVerbsShape;\n}\n\n/**\n * The Toaster's own record: the Island, the count and the overflow.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type ToasterEntry = {\n readonly ref: string;\n readonly component: 'toaster';\n /** `open`, `close`, `clear`, `acknowledge`, by state. */\n readonly actions: readonly string[];\n readonly island: {\n readonly open: boolean;\n /** `ref` of the notification the open Island shows; null while closed. */\n readonly current: string | null;\n };\n readonly count: number;\n readonly overflow: { readonly count: number; readonly pending: boolean };\n /** A mounted `Toaster` renders this controller. */\n readonly mounted: boolean;\n};\n\n/**\n * A form field as a reader sees it. Its value, default and placeholder stay inside Cloudlet.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type FormFieldEntry = {\n readonly name: string;\n readonly label: string;\n readonly kind: FormFieldKind;\n readonly required: boolean;\n /** null when the field sets no limit. */\n readonly maxLength: number | null;\n /** null when the field sets no input mode. */\n readonly inputMode: FormInputMode | null;\n /** The field holds non-blank text. */\n readonly filled: boolean;\n /**\n * Who wrote the value last: `app` (the field's default), `user` (the person) or `agent`; null\n * while nobody has and there is no default. An agent can't `fill` a field the person wrote.\n */\n readonly filledBy: 'app' | 'user' | 'agent' | null;\n /**\n * Why the last submit stopped at this field, if it did: the built-in message for a required or\n * too long field, and a fixed phrase when the form's own `validate` did not accept it, because\n * that text may quote what the person typed.\n */\n readonly error: string | null;\n};\n\n/**\n * A notification's primary action.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type ActionEntry = {\n readonly kind: 'command' | 'link' | 'form';\n /** The label the application gave the action. */\n readonly label: string;\n readonly status: 'idle' | 'pending' | 'failed';\n /**\n * Why the last attempt failed; null unless `status` is `failed`. For a form it is always\n * `Action failed`: the app's own text may quote what the person typed.\n */\n readonly message: string | null;\n /**\n * What the app lets an agent do with a command or a form: `allow`, `confirm` (a person approves)\n * or `deny`. `confirm` when the app set nothing; absent for a link.\n */\n readonly agent?: 'allow' | 'confirm' | 'deny';\n /** Only for a link. */\n readonly href?: string;\n /** Only for a form. */\n readonly fields?: readonly FormFieldEntry[];\n /**\n * Set when the last submit stopped on the form as a whole; only for a form. A fixed phrase when\n * the form's own `validate` said so, for the same reason as a field's `error`.\n */\n readonly error?: string | null;\n};\n\n/**\n * A notification's operation, without its attempt token.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type OperationEntry = {\n readonly status: OperationStatus;\n readonly attempt: number;\n readonly canCancel: boolean;\n readonly canRetry: boolean;\n readonly cancelRequested: boolean;\n};\n\n/**\n * One notification, in presentation order.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type NotificationEntry = {\n readonly ref: string;\n readonly component: 'notification';\n /** `dismiss`, `show` (with a mounted `Toaster`), `press`, `fill`, `submit`, `cancel`, `retry`, by state. */\n readonly actions: readonly string[];\n /** The title. */\n readonly label: string;\n /** The description as text; for rich content, its announcement. */\n readonly text: string | null;\n readonly kind: NotificationKind;\n readonly priority: Priority;\n readonly occurrences: number;\n readonly location: NotificationLocation;\n readonly remainingMs: number | null;\n readonly pauseReasons: readonly PauseReason[];\n readonly progress: { readonly kind: 'indeterminate' | 'determinate'; readonly value: number | null; readonly label: string | null } | null;\n readonly draft: boolean;\n readonly operation: OperationEntry | null;\n readonly action: ActionEntry | null;\n};\n\n/** @experimental The protocol may change before the bridge reaches 1.0. */\nexport type ToasterAgentEntry = ToasterEntry | NotificationEntry;\n\n/**\n * What {@link toasterAgent} returns: pass it to the bridge's `connect`.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface ToasterAgent extends AgentComponentShape<ToasterAgentEntry> {\n /** The same frozen array until the controller changes; empty after `dispose`. */\n snapshot(): readonly ToasterAgentEntry[];\n /**\n * Calls `listener` after every change of the controller with what changed and who changed it.\n * On a notification's record: `present` (`true` when it appears, `false` when it closes, with\n * the close reason in `reason`), `content` (the app updated it; both values are null), `action`\n * (`idle`, `pending`, `failed`), `operation` (`pending`, `cancel-requested`, `fulfilled`,\n * `rejected`, `cancelled`) and `field:<name>` (who wrote the form field last: `app`, `user`,\n * `agent` or null; only when the author changes, and never the text). On the Toaster's record:\n * `island` (the `ref` of the notification it shows, or null) and `overflow` (the missed count\n * after it was acknowledged). `label` is the notification's title. The array is empty when the\n * snapshot changed with no author, such as a pause.\n */\n subscribe(listener: (changes?: readonly AgentChangeShape[]) => void): () => void;\n /** Whether a step is available now and the class it needs; no side effects. */\n readonly check: (step: AgentStepCallShape) => AgentStepCheckShape;\n /** Reads the controller again and runs the step, unless it changed since it was approved. */\n readonly run: (step: AgentStepCallShape, context: AgentRunContextShape) => AgentRunOutcomeShape | PromiseLike<AgentRunOutcomeShape>;\n /**\n * Opens the Island on the step's notification for a person, at once or once they stop using the\n * Toaster, without moving focus, and says which in `note`.\n */\n readonly summon: (step: AgentStepCallShape) => AgentSummonOutcomeShape;\n /** What each verb of the `toaster` and `notification` records does, for an agent. */\n readonly verbs: AgentVerbsShape;\n}\n\n/** @experimental The protocol may change before the bridge reaches 1.0. */\nexport interface ToasterAgentOptions {\n /** The component's name and the prefix of its refs; matches `[a-z][a-z0-9-]*`. Default `toaster`. */\n readonly name?: string;\n}\n\nconst freeze = Object.freeze;\nconst EMPTY: readonly never[] = freeze([]);\nconst quote = JSON.stringify;\nconst TOASTER_VERBS: ReadonlySet<string> = new Set(['open', 'close', 'clear', 'acknowledge']);\nconst NOTIFICATION_VERBS: ReadonlySet<string> = new Set(['dismiss', 'show', 'press', 'fill', 'submit', 'cancel', 'retry']);\n// For an agent that has never seen this code: arguments in order, what the step does, when it\n// needs a person. One entry for every verb a record can list.\nconst VERBS: AgentVerbsShape = freeze({\n toaster: freeze({\n open: 'No arguments. Opens the Island on the notification it shows first. Needs a mounted Toaster; refused while the person is using it.',\n close: 'No arguments. Closes the open Island; refused while it holds a form the person or an agent started filling.',\n clear: 'No arguments. Closes every notification at once.',\n acknowledge: 'No arguments. Marks the notifications that did not fit as seen: overflow.pending turns false.',\n }),\n notification: freeze({\n dismiss: 'No arguments. Closes this notification; its record leaves the snapshot.',\n show: 'No arguments. Opens the Island on this notification. Needs a mounted Toaster; refused while the person is using it.',\n press: 'No arguments. Runs the command action (action.kind \"command\") and waits for it: success closes the notification, result \"pending\" means it is still working. Under action.agent \"confirm\" it may need a person to approve. A link action has no verb: the bridge never opens it; its address is action.href.',\n fill: 'args [field name, text]: the field\\'s name from action.fields[].name, not its label, and a string. Writes the field as the agent; never over text the person typed.',\n submit: 'No arguments. Sends the form action (action.kind \"form\") and waits for it: success closes the notification, result \"pending\" means it is still working. Under action.agent \"confirm\" it may need a person to approve. A refusal names the fields that were not accepted.',\n cancel: 'No arguments. Asks the running operation to stop; result \"requested\".',\n retry: 'No arguments. Starts the failed operation again; result \"started\".',\n }),\n});\nconst STRICTNESS = { allow: 0, confirm: 1, deny: 2 } as const;\nconst DONE: AgentRunOutcomeShape = freeze({ status: 'done' });\nconst GONE: AgentRunOutcomeShape = freeze({ status: 'done', gone: true });\nconst STALE: AgentRunOutcomeShape = freeze({ status: 'stale' });\nconst UNAVAILABLE: AgentRunOutcomeShape = freeze({ status: 'unavailable' });\n\n// A form's `validate` and `errorMessage` see what the person typed and may quote it, so their\n// text stays with the person in the Island: an agent reads these instead.\nconst FORM_REJECTED = \"Not accepted by the form's own check\";\nconst FORM_FAILED = 'Action failed';\n\n// Refusals the adapter words itself; the bridge words the rest from the record's `actions`.\n// Labels and titles come from the app, so they are quoted.\nconst texts = {\n noScreen: (action: string) => `No Toaster is on screen: ${quote(action)} needs one.`,\n noArguments: (step: AgentStepCallShape) => `${quote(step.action)} on ${quote(step.ref)} takes no arguments.`,\n fillArguments: (step: AgentStepCallShape) => `${quote(step.action)} on ${quote(step.ref)} takes a field name and a value.`,\n noField: (step: AgentStepCallShape, name: string, names: readonly string[]) =>\n `No field ${quote(name)} on ${quote(step.ref)}. Fields: ${names.map((item) => quote(item)).join(', ')}.`,\n notText: (field: string) => `The value for ${quote(field)} must be a string.`,\n tooLong: (field: string, limit: number) => `${quote(field)} takes at most ${limit} characters.`,\n personTyped: (field: string) => `The person typed in ${quote(field)}. An agent can't overwrite it.`,\n notSent: (label: string, messages: string) => `${quote(label)} was not sent. ${messages}`,\n running: (label: string) => `${quote(label)} is already running.`,\n failed: (label: string, message: string) => `${quote(label)} failed: ${message}`,\n finished: 'This operation has already finished.',\n cancelRequested: 'Cancelling this operation was already requested.',\n notCancellable: \"This operation can't be cancelled.\",\n stillRunning: \"This operation is still running, so it can't be retried yet.\",\n notRetryable: \"This operation can't be retried.\",\n busy: 'The person is using the Island. Try again later.',\n islandOpen: 'The Island is open on it.',\n islandLater: 'The Island will open on it once they stop using it.',\n noToaster: 'No Toaster is on screen, so tell them what it does.',\n};\n\n/** A step as the adapter sees it right now: refused, or allowed under a class with a way to run it. */\ntype Plan =\n | { readonly available: false; readonly message?: string }\n | {\n readonly available: true;\n readonly permission: AgentPermissionShape;\n readonly names?: AgentStepNamesShape;\n /** The action object a press or a submit would run. */\n readonly subject?: object;\n readonly perform: (context: AgentRunContextShape) => AgentRunOutcomeShape | Promise<AgentRunOutcomeShape>;\n };\n\nconst NO_AUTHORS: FormReading['authors'] = new Map();\nconst NOT_AVAILABLE: Plan = freeze({ available: false });\nconst refuse = (message: string): Plan => freeze({ available: false, message });\nconst allowed = (perform: () => AgentRunOutcomeShape): Plan => freeze({ available: true, permission: 'allow', perform });\ntype PortResult = { readonly status: string; readonly reason?: string };\n/** A port refusal after the plan said yes: the state changed in between, so the step is unavailable. */\nconst outcome = (result: PortResult, done: AgentRunOutcomeShape, words: Readonly<Record<string, string>> = {}): AgentRunOutcomeShape => {\n if (result.status !== 'rejected') return done;\n const message = result.reason === undefined ? undefined : words[result.reason];\n return message === undefined ? UNAVAILABLE : freeze({ status: 'unavailable', message });\n};\n\n/**\n * Lets an agent read and drive a controller through the kit's agent bridge:\n * `agent.connect(toasterAgent(controller))`. It touches no DOM, starts no timers, never takes the\n * host from a `Toaster` and never moves focus. Form values never reach the snapshot.\n *\n * Steps: `open`, `close`, `clear` and `acknowledge` on the Toaster record; `show`, `dismiss`,\n * `press`, `fill`, `submit`, `cancel` and `retry` on a notification. `open` and `show` need a\n * mounted `Toaster`. `press` and `submit` follow the action's `agent` marker; every other step is\n * allowed unless the bridge's `allow` says no. `fill` (`args: [name, value]`) writes a form field\n * as the agent, never over what the person typed, and makes a draft as typing does; the snapshot\n * says who wrote each field (`filledBy`), never what. A press or submit that needs a person opens\n * the Island on its notification for them: at once, or after the attention delay once they stop\n * using the Toaster. While they use it (hover, focus, a gesture, a draft in the open Island, the\n * agent's own included), `open` and `show` are refused, and so is `close` over a draft.\n *\n * @throws TypeError for a controller that this copy of `@cloudlet/toast` did not create.\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport function toasterAgent<Slot, Signal extends CancellationSignal>(\n controller: Omit<CloudletController<Slot, Signal>, 'track'>,\n options?: ToasterAgentOptions,\n): ToasterAgent {\n const name = options?.name ?? 'toaster';\n const port = createToasterPort<Slot>(controller);\n // A number per handle, so a closed notification's ref is never handed to another one.\n const refs = new WeakMap<NotificationHandle, string>();\n let issued = 0;\n const refOf = (handle: NotificationHandle): string => {\n let ref = refs.get(handle);\n if (ref === undefined) refs.set(handle, ref = `${name}:${++issued}`);\n return ref;\n };\n // What the last change records said about each open notification, kept while someone listens.\n type Known = {\n label: string | undefined;\n action: 'idle' | 'pending' | 'failed';\n operation: { readonly token: string; value: string } | null;\n authors: FormReading['authors'];\n };\n const known = new Map<NotificationHandle, Known>();\n let islandRef: string | null = null;\n // The revision `known` was read at; a commit up to it is already in there.\n let seeded = 0;\n const listeners = new Set<(changes?: readonly AgentChangeShape[]) => void>();\n let stop: (() => void) | undefined;\n let source: ToasterReading<Slot> | undefined;\n let entries: readonly ToasterAgentEntry[] = EMPTY;\n // The notifications of the current snapshot by ref, for steps.\n let targets: ReadonlyMap<string, { readonly item: NotificationSnapshot<Slot>; readonly entry: NotificationEntry }> = new Map();\n\n const snapshot = (): readonly ToasterAgentEntry[] => {\n const reading = port.read();\n if (reading === source) return entries;\n source = reading;\n const state = reading.controller;\n if (state.disposed) { targets = new Map(); return entries = EMPTY; }\n const byHandle = new Map(state.notifications.map((item) => [item.handle, item] as const));\n const island = state.island;\n const count = state.stack.length;\n const found = new Map<string, { readonly item: NotificationSnapshot<Slot>; readonly entry: NotificationEntry }>();\n // Refs are issued in presentation order, so the top notification gets the lower number.\n const notifications = state.stack.map((handle) => {\n const item = byHandle.get(handle)!;\n const entry = notification(item, refOf(handle), island.open && island.current === handle, reading.mounted, reading.forms.get(handle));\n found.set(entry.ref, { item, entry });\n return entry;\n });\n targets = found;\n const toaster: ToasterEntry = freeze({\n ref: name, component: 'toaster' as const,\n actions: freeze([\n ...(!island.open && count > 0 && reading.mounted ? ['open'] : []),\n ...(island.open ? ['close'] : []),\n ...(count > 0 ? ['clear'] : []),\n ...(state.overflow.pending ? ['acknowledge'] : []),\n ]),\n island: freeze({ open: island.open, current: island.current ? refOf(island.current) : null }),\n count,\n overflow: freeze({ count: state.overflow.count, pending: state.overflow.pending }),\n mounted: reading.mounted,\n });\n return entries = freeze([toaster, ...notifications]);\n };\n\n /** Reads the step against the controller as it is now; `check` and `run` both start here. */\n const plan = (step: AgentStepCallShape): Plan => {\n const current = snapshot();\n const mounted = source?.mounted ?? false;\n const { action } = step;\n if (step.ref === name && current.length) {\n if (!TOASTER_VERBS.has(action)) return NOT_AVAILABLE;\n if (step.args.length) return refuse(texts.noArguments(step));\n if (action === 'open' && !mounted) return refuse(texts.noScreen(action));\n if (!current[0]!.actions.includes(action)) return NOT_AVAILABLE;\n // A busy person is not interrupted; only a draft stops `close`, which a person's Escape would collapse.\n if (action === 'open' && source!.busy) return refuse(texts.busy);\n if (action === 'close' && holdsDraft()) return refuse(texts.busy);\n switch (action) {\n case 'open': return allowed(() => outcome(port.open(), DONE, { 'no-host': texts.noScreen(action), busy: texts.busy }));\n case 'close': return allowed(() => outcome(port.close(), DONE, { busy: texts.busy }));\n case 'clear': return allowed(() => outcome(port.clear(), DONE));\n default: return allowed(() => outcome(port.acknowledge(), DONE));\n }\n }\n const target = targets.get(step.ref);\n if (!target || !NOTIFICATION_VERBS.has(action)) return NOT_AVAILABLE;\n const { item, entry } = target;\n if (action === 'fill') return fillPlan(step, item);\n if (step.args.length) return refuse(texts.noArguments(step));\n const { handle } = item;\n switch (action) {\n case 'show':\n if (!mounted) return refuse(texts.noScreen(action));\n break;\n case 'press': {\n const command = item.content.action;\n return command?.kind === 'command' ? pressPlan(item, command) : NOT_AVAILABLE;\n }\n case 'submit': {\n const form = item.content.action;\n return form?.kind === 'form' ? pressPlan(item, form) : NOT_AVAILABLE;\n }\n case 'cancel': {\n const operation = item.operation;\n if (!operation) return NOT_AVAILABLE;\n if (operation.status !== 'pending') return refuse(texts.finished);\n if (operation.cancelRequested) return refuse(texts.cancelRequested);\n if (!operation.canCancel) return refuse(texts.notCancellable);\n break;\n }\n case 'retry': {\n const operation = item.operation;\n if (!operation) return NOT_AVAILABLE;\n if (operation.status === 'pending') return refuse(texts.stillRunning);\n if (!operation.canRetry) return refuse(texts.notRetryable);\n break;\n }\n }\n if (!entry.actions.includes(action)) return NOT_AVAILABLE;\n if (action === 'show' && source!.busy) return refuse(texts.busy);\n switch (action) {\n case 'show': return allowed(() => outcome(port.show(handle), DONE, { 'no-host': texts.noScreen(action), busy: texts.busy }));\n case 'dismiss': return allowed(() => outcome(port.dismiss(handle), GONE));\n case 'cancel': return allowed(() => {\n const result = port.cancel(handle);\n return result.status === 'requested' ? freeze({ status: 'done', result: 'requested' })\n : outcome(result.status === 'unchanged' ? { status: 'rejected', reason: result.reason } : result, DONE, {\n settled: texts.finished, 'already-requested': texts.cancelRequested, 'not-cancellable': texts.notCancellable,\n });\n });\n default: return allowed(() => outcome(port.retry(handle), freeze({ status: 'done', result: 'started' }), {\n 'already-pending': texts.stillRunning, 'not-retryable': texts.notRetryable,\n }));\n }\n };\n\n /** The open Island shows a notification whose form holds a draft. */\n const holdsDraft = (): boolean => {\n const state = source!.controller;\n const current = state.island.current;\n return current !== null && state.notifications.some((item) => item.handle === current && item.draft);\n };\n\n // An agent's value goes in like a person's keystrokes, except over what the person typed. The\n // step's text names the field, never a value.\n const fillPlan = (step: AgentStepCallShape, item: NotificationSnapshot<Slot>): Plan => {\n const form = item.content.action;\n if (form?.kind !== 'form') return NOT_AVAILABLE;\n const [name, value] = step.args;\n if (step.args.length !== 2 || typeof name !== 'string') return refuse(texts.fillArguments(step));\n const field = form.fields.find((candidate) => candidate.name === name);\n if (!field) return refuse(texts.noField(step, name, form.fields.map((candidate) => candidate.name)));\n if (typeof value !== 'string') return refuse(texts.notText(field.label));\n const words = {\n 'already-pending': texts.running(form.label),\n 'too-long': texts.tooLong(field.label, field.maxLength ?? 0),\n 'person-typed': texts.personTyped(field.label),\n };\n if (item.action.status === 'pending') return refuse(words['already-pending']);\n if (field.maxLength !== undefined && value.length > field.maxLength) return refuse(words['too-long']);\n if (source!.forms.get(item.handle)?.authors.get(name) === 'user') return refuse(words['person-typed']);\n return allowed(() => outcome(port.fill(item.handle, name, value), DONE, words));\n };\n\n /** A command's press or a form's submit: both follow the action's marker and wait for its run. */\n const pressPlan = (item: NotificationSnapshot<Slot>, action: CommandAction | FormAction): Plan => {\n const { label } = action;\n const permission = action.agent ?? 'confirm';\n const names = freeze({ target: label, within: item.content.title });\n // A denied press never runs, so it is reported before its state.\n if (permission !== 'deny' && item.action.status === 'pending') return refuse(texts.running(label));\n return freeze({\n available: true, permission, names, subject: action,\n async perform({ signal, approved }: AgentRunContextShape): Promise<AgentRunOutcomeShape> {\n const started = port.press(item.handle, approved, signal);\n if (!(started instanceof Promise)) {\n return started.reason === 'stale' ? STALE : outcome(started, DONE, { 'already-pending': texts.running(label) });\n }\n const ended = await started;\n if (ended.status === 'done') return GONE;\n if (ended.status === 'replaced') return STALE;\n if (ended.status === 'failed') return freeze({ status: 'failed', message: texts.failed(label, action.kind === 'form' ? FORM_FAILED : ended.message) });\n if (ended.status === 'invalid') return freeze({ status: 'failed', message: texts.notSent(label, describe(action as FormAction, ended.errors)) });\n return freeze({ status: 'done', result: 'pending', ...(ended.gone ? { gone: true } : {}) });\n },\n });\n };\n\n // What a checked press or submit would have run, by step object: the bridge approves a step by\n // its ref and verb, so the action it named to the app or the person is held here until it runs.\n const checked = new WeakMap<AgentStepCallShape, object>();\n\n const check = (step: AgentStepCallShape): AgentStepCheckShape => {\n const verdict = plan(step);\n if (!verdict.available) return verdict;\n if (verdict.subject) checked.set(step, verdict.subject);\n return freeze({ available: true, permission: verdict.permission, ...(verdict.names ? { names: verdict.names } : {}) });\n };\n\n // The bridge approved the step under `approved`; the controller is read again before anything runs.\n const run = (step: AgentStepCallShape, context: AgentRunContextShape): AgentRunOutcomeShape | Promise<AgentRunOutcomeShape> => {\n const verdict = plan(step);\n if (!verdict.available) return verdict.message === undefined ? UNAVAILABLE : freeze({ status: 'unavailable', message: verdict.message });\n if (STRICTNESS[verdict.permission] > STRICTNESS[context.approved]) return STALE;\n // The app replaced the action while the step waited: the approval was for the other one.\n const subject = checked.get(step);\n if (subject !== undefined && subject !== verdict.subject) return STALE;\n return verdict.perform(context);\n };\n\n // A step only a person may take: the Island opens on its notification for them, through the\n // attention queue, so a person busy with the Toaster is not interrupted.\n const summon = (step: AgentStepCallShape): AgentSummonOutcomeShape => {\n snapshot();\n const target = targets.get(step.ref);\n if (!target) return false;\n const result = port.summon(target.item.handle);\n if (result.status === 'rejected') return result.reason === 'no-host' ? freeze({ reached: false, note: texts.noToaster }) : false;\n return freeze({ reached: true, note: result.status === 'waiting' ? texts.islandLater : texts.islandOpen });\n };\n\n /**\n * The records of one committed change: its events in order, then what only the state shows (an\n * action back to idle, a field's new author, the Island). A form's values are never read here.\n */\n const collect = (commit: PortCommit<Slot>): readonly AgentChangeShape[] => {\n // The commit's own state, not the latest: a listener before this one may have committed again.\n const state = commit.controller;\n // Subscribed while this commit was still queued: what it did was read then.\n if (state.revision <= seeded) return EMPTY;\n const { events } = commit;\n const live = new Map(state.notifications.map((item) => [item.handle, item] as const));\n for (const [handle, entry] of known) {\n const item = live.get(handle);\n if (item) entry.label = item.content.title;\n }\n const changes: AgentChangeShape[] = [];\n // Who changed a notification's content in this commit: the author of what follows from it.\n const touched = new Map<NotificationHandle, ChangeSource>();\n const push = (handle: NotificationHandle, key: string, value: AgentValueShape, previous: AgentValueShape, by: ChangeSource, reason?: string): void => {\n const label = known.get(handle)?.label;\n changes.push(freeze({\n ref: refOf(handle), component: 'notification', ...(label === undefined ? {} : { label }), key, value, previous,\n ...(reason === undefined ? {} : { reason }), source: by,\n }));\n };\n for (const event of events) {\n switch (event.type) {\n case 'admitted': {\n // The number is issued here, so a notification closed before anyone reads still has one.\n refOf(event.handle);\n known.set(event.handle, {\n label: live.get(event.handle)?.content.title, action: 'idle', operation: null,\n authors: commit.authors.get(event.handle) ?? NO_AUTHORS,\n });\n push(event.handle, 'present', true, false, event.source);\n break;\n }\n case 'closed':\n push(event.handle, 'present', false, true, event.source, event.reason);\n known.delete(event.handle);\n break;\n case 'updated':\n touched.set(event.handle, event.source);\n push(event.handle, 'content', null, null, event.source);\n break;\n case 'action-started':\n case 'action-failed': {\n const entry = known.get(event.handle);\n if (!entry) break;\n const next = event.type === 'action-started' ? 'pending' : 'failed';\n push(event.handle, 'action', next, entry.action, event.source);\n entry.action = next;\n break;\n }\n case 'operation-started': {\n const entry = event.handle && known.get(event.handle);\n if (!entry) break;\n touched.set(event.handle!, event.source);\n push(event.handle!, 'operation', 'pending', entry.operation?.value ?? null, event.source);\n entry.operation = { token: event.token, value: 'pending' };\n break;\n }\n case 'cancellation-requested':\n case 'operation-settled': {\n const entry = event.handle && known.get(event.handle);\n // An attempt that a newer one replaced no longer speaks for the notification.\n if (!entry || entry.operation?.token !== event.token) break;\n if (event.type === 'operation-settled') touched.set(event.handle!, event.source);\n const next = event.type === 'operation-settled' ? event.status : 'cancel-requested';\n push(event.handle!, 'operation', next, entry.operation.value, event.source);\n entry.operation.value = next;\n break;\n }\n case 'overflow-acknowledged':\n changes.push(freeze({ ref: name, component: 'toaster', key: 'overflow', value: 0, previous: event.count, source: event.source }));\n break;\n }\n }\n for (const [handle, entry] of known) {\n // A notification missing here closed in a later commit; its own records follow.\n const item = live.get(handle);\n if (!item) continue;\n const by = touched.get(handle);\n if (item.action.status === 'idle' && entry.action !== 'idle') {\n push(handle, 'action', 'idle', entry.action, by ?? 'system');\n entry.action = 'idle';\n }\n const authors = commit.authors.get(handle) ?? NO_AUTHORS;\n if (authors !== entry.authors) {\n // In the form's own order; a field of the form that was replaced comes after them.\n const action = item.content.action;\n const names = action?.kind === 'form' ? action.fields.map((field) => field.name) : [];\n for (const field of new Set([...names, ...entry.authors.keys(), ...authors.keys()])) {\n const next = authors.get(field) ?? null;\n const previous = entry.authors.get(field) ?? null;\n // A new author is the source; a field emptied with its form was replaced by the app.\n if (next !== previous) push(handle, `field:${field}`, next, previous, next ?? by ?? 'app');\n }\n entry.authors = authors;\n }\n }\n const current = state.island.current ? refOf(state.island.current) : null;\n if (current !== islandRef) {\n changes.push(freeze({\n ref: name, component: 'toaster', key: 'island', value: current, previous: islandRef,\n source: state.island.source ?? commit.closedBy ?? 'system',\n }));\n islandRef = current;\n }\n return freeze(changes);\n };\n\n const subscribe = (listener: (changes?: readonly AgentChangeShape[]) => void): (() => void) => {\n // The same function may subscribe twice; each subscription is removed on its own.\n const own = (changes?: readonly AgentChangeShape[]): void => { listener(changes); };\n if (!listeners.size) {\n // Refs of what is already there are issued as a snapshot does, top first.\n snapshot();\n const reading = port.read();\n const state = reading.controller;\n known.clear();\n for (const item of state.notifications) {\n const operation = item.operation;\n known.set(item.handle, {\n label: item.content.title, action: item.action.status,\n operation: operation ? { token: operation.token, value: operation.status === 'pending' && operation.cancelRequested ? 'cancel-requested' : operation.status } : null,\n authors: reading.forms.get(item.handle)?.authors ?? NO_AUTHORS,\n });\n }\n islandRef = state.island.current ? refOf(state.island.current) : null;\n seeded = state.revision;\n stop = port.subscribe((commit) => {\n const changes = collect(commit);\n // Every listener hears the change; the first error goes on to the controller's diagnostics.\n let failure: { readonly error: unknown } | undefined;\n for (const each of [...listeners]) {\n if (!listeners.has(each)) continue;\n try { each(changes); } catch (error) { failure ??= { error }; }\n }\n if (failure) throw failure.error;\n });\n }\n listeners.add(own);\n return () => {\n if (!listeners.delete(own) || listeners.size) return;\n stop?.();\n stop = undefined;\n known.clear();\n };\n };\n\n return freeze({ protocol: 1 as const, name, snapshot, subscribe, check, run, summon, verbs: VERBS });\n}\n\n/**\n * Why a form was not sent, by field label and never with a value: the built-in messages as the\n * person sees them, and for the app's own `validate` only which fields it did not accept.\n */\nfunction describe(form: FormAction, errors: FormErrors): string {\n if (errors.broken) return `${FORM_FAILED}.`;\n if (errors.authored) {\n // Own keys only, as below.\n const labels = form.fields.flatMap((field) => Object.hasOwn(errors.fields, field.name) ? [quote(field.label)] : []);\n return `The form's own check did not accept ${labels.length ? labels.join(', ') : 'it'}.`;\n }\n const sentence = (message: string) => /[.!?]$/.test(message.trim()) ? message.trim() : `${message.trim()}.`;\n return [\n // Own keys only: a field named `constructor` must not read `Object.prototype`.\n ...form.fields.flatMap((field) => Object.hasOwn(errors.fields, field.name) ? [`${quote(field.label)}: ${sentence(errors.fields[field.name]!)}`] : []),\n ...(errors.form ? [sentence(errors.form)] : []),\n ].join(' ');\n}\n\nfunction notification<Slot>(item: NotificationSnapshot<Slot>, ref: string, shown: boolean, mounted: boolean, form: FormReading | undefined): NotificationEntry {\n const { content } = item;\n const description = content.description;\n const progress = content.progress;\n const operation = item.operation;\n const action = actionEntry(item, form);\n // `deny` stops pressing and submitting only: a person can still submit what an agent filled.\n const ready = item.action.status !== 'pending';\n const may = ready && action?.agent !== 'deny';\n return freeze({\n ref, component: 'notification' as const,\n actions: freeze([\n 'dismiss',\n ...(!shown && mounted ? ['show'] : []),\n ...(action?.kind === 'command' && may ? ['press'] : []),\n ...(action?.kind === 'form' && ready ? ['fill'] : []),\n ...(action?.kind === 'form' && may ? ['submit'] : []),\n ...(operation?.canCancel ? ['cancel'] : []),\n ...(operation?.canRetry ? ['retry'] : []),\n ]),\n label: content.title,\n text: description ? description.kind === 'text' ? description.text : description.announcement : null,\n kind: item.kind,\n priority: item.priority,\n occurrences: item.occurrences,\n location: item.location,\n remainingMs: item.remainingMs,\n pauseReasons: freeze([...item.pauseReasons]),\n progress: progress ? freeze({\n kind: progress.kind,\n value: progress.kind === 'determinate' ? progress.value : null,\n label: progress.label ?? null,\n }) : null,\n draft: item.draft,\n operation: operation ? freeze({\n status: operation.status, attempt: operation.attempt, canCancel: operation.canCancel,\n canRetry: operation.canRetry, cancelRequested: operation.cancelRequested,\n }) : null,\n action,\n });\n}\n\nfunction actionEntry<Slot>(item: NotificationSnapshot<Slot>, form: FormReading | undefined): ActionEntry | null {\n const action = item.content.action;\n if (!action) return null;\n const state = item.action;\n const common = {\n kind: action.kind, label: action.label, status: state.status,\n message: state.status !== 'failed' ? null : action.kind === 'form' ? FORM_FAILED : state.message,\n };\n if (action.kind === 'link') return freeze({ ...common, href: action.href });\n if (action.kind === 'command') return freeze({ ...common, agent: action.agent ?? 'confirm' });\n const errors = form?.errors;\n return freeze({\n ...common,\n agent: action.agent ?? 'confirm',\n fields: freeze(action.fields.map((field) => freeze({\n name: field.name, label: field.label, kind: field.kind, required: field.required ?? false,\n maxLength: field.maxLength ?? null, inputMode: field.inputMode ?? null,\n filled: form?.filled.has(field.name) ?? false,\n filledBy: form?.authors.get(field.name) ?? null,\n // Own keys only: a field named `constructor` must not read `Object.prototype`.\n error: errors && Object.hasOwn(errors.fields, field.name) ? errors.authored ? FORM_REJECTED : errors.fields[field.name]! : null,\n }))),\n error: errors?.form ? errors.broken ? FORM_FAILED : errors.authored ? FORM_REJECTED : errors.form : null,\n });\n}\n"],"mappings":";;AA0TA,IAAMA,IAAS,OAAO,QAChBC,IAA0BD,EAAO,CAAC,CAAC,GACnCE,IAAQ,KAAK,WACbC,oBAAqC,IAAI,IAAI;CAAC;CAAQ;CAAS;CAAS;AAAa,CAAC,GACtFC,oBAA0C,IAAI,IAAI;CAAC;CAAW;CAAQ;CAAS;CAAQ;CAAU;CAAU;AAAO,CAAC,GAGnHC,IAAyBL,EAAO;CACpC,SAASA,EAAO;EACd,MAAM;EACN,OAAO;EACP,OAAO;EACP,aAAa;CACf,CAAC;CACD,cAAcA,EAAO;EACnB,SAAS;EACT,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,OAAO;CACT,CAAC;AACH,CAAC,GACKM,IAAa;CAAE,OAAO;CAAG,SAAS;CAAG,MAAM;AAAE,GAC7CC,IAA6BP,EAAO,EAAE,QAAQ,OAAO,CAAC,GACtDQ,IAA6BR,EAAO;CAAE,QAAQ;CAAQ,MAAM;AAAK,CAAC,GAClES,IAA8BT,EAAO,EAAE,QAAQ,QAAQ,CAAC,GACxDU,IAAoCV,EAAO,EAAE,QAAQ,cAAc,CAAC,GAIpEW,IAAgB,wCAChBC,IAAc,iBAIdC,IAAQ;CACZ,WAAW,MAAmB,4BAA4BX,EAAMY,CAAM,EAAE;CACxE,cAAc,MAA6B,GAAGZ,EAAMa,EAAK,MAAM,EAAE,MAAMb,EAAMa,EAAK,GAAG,EAAE;CACvF,gBAAgB,MAA6B,GAAGb,EAAMa,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AAO;CACpB,IAAMsC,IAAQlC,EAAK,QACb8F,IAAS;EACb,MAAMlG,EAAO;EAAM,OAAOA,EAAO;EAAO,QAAQsC,EAAM;EACtD,SAASA,EAAM,WAAW,WAAkBtC,EAAO,SAAS,SAASF,IAAcwC,EAAM,UAApD;CACvC;CACA,IAAItC,EAAO,SAAS,QAAQ,OAAOd,EAAO;EAAE,GAAGgH;EAAQ,MAAMlG,EAAO;CAAK,CAAC;CAC1E,IAAIA,EAAO,SAAS,WAAW,OAAOd,EAAO;EAAE,GAAGgH;EAAQ,OAAOlG,EAAO,SAAS;CAAU,CAAC;CAC5F,IAAMwF,IAASlC,GAAM;CACrB,OAAOpE,EAAO;EACZ,GAAGgH;EACH,OAAOlG,EAAO,SAAS;EACvB,QAAQd,EAAOc,EAAO,OAAO,KAAK,MAAUd,EAAO;GACjD,MAAMmB,EAAM;GAAM,OAAOA,EAAM;GAAO,MAAMA,EAAM;GAAM,UAAUA,EAAM,YAAY;GACpF,WAAWA,EAAM,aAAa;GAAM,WAAWA,EAAM,aAAa;GAClE,QAAQiD,GAAM,OAAO,IAAIjD,EAAM,IAAI,KAAK;GACxC,UAAUiD,GAAM,QAAQ,IAAIjD,EAAM,IAAI,KAAK;GAE3C,OAAOmF,KAAU,OAAO,OAAOA,EAAO,QAAQnF,EAAM,IAAI,IAAImF,EAAO,WAAW3F,IAAgB2F,EAAO,OAAOnF,EAAM,QAAS;EAC7H,CAAC,CAAC,CAAC;EACH,OAAOmF,GAAQ,OAAOA,EAAO,SAAS1F,IAAc0F,EAAO,WAAW3F,IAAgB2F,EAAO,OAAO;CACtG,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"agent.js","names":["freeze","EMPTY","quote","TOASTER_VERBS","NOTIFICATION_VERBS","VERBS","STRICTNESS","DONE","GONE","STALE","UNAVAILABLE","FORM_REJECTED","FORM_FAILED","texts","action","step","name","names","item","field","limit","label","messages","message","NO_AUTHORS","NOT_AVAILABLE","refuse","allowed","outcome","result","done","words","toasterAgent","options","port","createToasterPort","controller","refs","issued","refOf","ref","handle","known","islandRef","seeded","listeners","stop","source","entries","targets","snapshot","reading","state","byHandle","island","count","found","notifications","entry","notification","plan","current","mounted","holdsDraft","target","fillPlan","command","pressPlan","form","operation","value","candidate","permission","started","approved","signal","ended","describe","checked","check","verdict","run","context","subject","summon","collect","commit","live","changes","touched","push","reason","by","event","events","next","authors","previous","own","listener","revision","each","error","errors","labels","sentence","description","content","progress","actionEntry","ready","may","shown","common"],"sources":["../src/agent.ts"],"sourcesContent":["import type { CloudletController } from './contracts/controller.js';\nimport type { ChangeSource } from './contracts/events.js';\nimport type { NotificationHandle } from './contracts/identity.js';\nimport type { FormErrors } from './contracts/internal.js';\nimport type { CommandAction, FormAction, FormFieldKind, FormInputMode, NotificationKind, Priority } from './contracts/notifications.js';\nimport type { CancellationSignal, OperationStatus } from './contracts/operations.js';\nimport type { NotificationLocation, NotificationSnapshot, PauseReason } from './contracts/snapshots.js';\nimport { createToasterPort, type FormReading, type PortCommit, type ToasterReading } from './core/agent-port.js';\n\n// The Toaster's side of the agent bridge. Its protocol types are declared here structurally:\n// this package never imports the bridge package, not even its types.\n\n/**\n * One record of an agent snapshot, as the bridge reads it.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentEntryShape = {\n readonly ref: string;\n readonly component: string;\n readonly actions: readonly string[];\n readonly [key: string]: unknown;\n};\n\n/**\n * A cancellation signal as the bridge hands it out; an `AbortSignal` at runtime.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentSignalShape {\n readonly aborted: boolean;\n readonly reason: unknown;\n readonly throwIfAborted: () => void;\n readonly addEventListener: (type: 'abort', listener: () => void, options?: { readonly once?: boolean }) => void;\n readonly removeEventListener: (type: 'abort', listener: () => void) => void;\n}\n\n/**\n * A value a step may return to the agent.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentValueShape = string | number | boolean | null | readonly AgentValueShape[] | { readonly [key: string]: AgentValueShape };\n\n/**\n * What a step may do: on its own, with approval, or never.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentPermissionShape = 'allow' | 'confirm' | 'deny';\n\n/**\n * A step as the bridge hands it to a component.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentStepCallShape {\n readonly ref: string;\n readonly action: string;\n readonly args: readonly unknown[];\n}\n\n/**\n * How a person names what a step acts on, for the bridge's messages.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentStepNamesShape {\n readonly target: string;\n readonly within?: string;\n}\n\n/**\n * A component's answer to the bridge's `check`.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentStepCheckShape =\n | { readonly available: true; readonly permission: AgentPermissionShape; readonly names?: AgentStepNamesShape }\n | { readonly available: false; readonly message?: string };\n\n/**\n * What the bridge's `run` receives besides the step.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentRunContextShape {\n readonly signal: AgentSignalShape;\n readonly approved: 'allow' | 'confirm';\n}\n\n/**\n * A component's answer to the bridge's `run`.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentRunOutcomeShape =\n | { readonly status: 'done'; readonly result?: AgentValueShape; readonly gone?: boolean }\n | { readonly status: 'failed'; readonly message: string }\n | { readonly status: 'unavailable'; readonly message?: string }\n | { readonly status: 'stale' };\n\n/**\n * A component's answer to the bridge's `summon`.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type AgentSummonOutcomeShape = boolean | { readonly reached: boolean; readonly note: string };\n\n/**\n * One change a component reports to the bridge's subscribers: what changed on which record and who\n * changed it.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentChangeShape {\n readonly ref: string;\n readonly component: string;\n readonly label?: string;\n readonly key: string;\n readonly value: AgentValueShape;\n readonly previous: AgentValueShape;\n readonly reason?: string;\n readonly source: 'user' | 'agent' | 'app' | 'system';\n}\n\n/**\n * What a component's verbs do, by kind of record: each verb with a line or two for an agent.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentVerbsShape {\n readonly [component: string]: { readonly [verb: string]: string };\n}\n\n/**\n * What a component hands to the bridge's `connect`. `check` and `run` come together, `summon` is\n * optional, and a read-only component leaves all three out.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface AgentComponentShape<Entry extends AgentEntryShape = AgentEntryShape> {\n readonly protocol: 1;\n readonly name: string;\n snapshot(): readonly Entry[];\n subscribe(listener: (changes?: readonly AgentChangeShape[]) => void): () => void;\n readonly check?: (step: AgentStepCallShape) => AgentStepCheckShape;\n readonly run?: (step: AgentStepCallShape, context: AgentRunContextShape) => AgentRunOutcomeShape | PromiseLike<AgentRunOutcomeShape>;\n readonly summon?: (step: AgentStepCallShape) => AgentSummonOutcomeShape;\n readonly verbs?: AgentVerbsShape;\n}\n\n/**\n * The Toaster's own record: the Island, the count and the overflow.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type ToasterEntry = {\n readonly ref: string;\n readonly component: 'toaster';\n /** `open`, `close`, `clear`, `acknowledge`, by state. */\n readonly actions: readonly string[];\n readonly island: {\n readonly open: boolean;\n /** `ref` of the notification the open Island shows; null while closed. */\n readonly current: string | null;\n };\n readonly count: number;\n readonly overflow: { readonly count: number; readonly pending: boolean };\n /** A mounted `Toaster` renders this controller. */\n readonly mounted: boolean;\n};\n\n/**\n * A form field as a reader sees it. Its value, default and placeholder stay inside Cloudlet.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type FormFieldEntry = {\n readonly name: string;\n readonly label: string;\n readonly kind: FormFieldKind;\n readonly required: boolean;\n /** null when the field sets no limit. */\n readonly maxLength: number | null;\n /** null when the field sets no input mode. */\n readonly inputMode: FormInputMode | null;\n /** The field holds non-blank text. */\n readonly filled: boolean;\n /**\n * Who wrote the value last: `app` (the field's default), `user` (the person) or `agent`; null\n * while nobody has and there is no default. An agent can't `fill` a field the person wrote.\n */\n readonly filledBy: 'app' | 'user' | 'agent' | null;\n /**\n * Why the last submit stopped at this field, if it did: the built-in message for a required or\n * too long field, and a fixed phrase when the form's own `validate` did not accept it, because\n * that text may quote what the person typed.\n */\n readonly error: string | null;\n};\n\n/**\n * A notification's primary action.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type ActionEntry = {\n readonly kind: 'command' | 'link' | 'form';\n /** The label the application gave the action. */\n readonly label: string;\n readonly status: 'idle' | 'pending' | 'failed';\n /**\n * Why the last attempt failed; null unless `status` is `failed`. For a form it is always\n * `Action failed`: the app's own text may quote what the person typed.\n */\n readonly message: string | null;\n /**\n * What the app lets an agent do with a command or a form: `allow`, `confirm` (a person approves)\n * or `deny`. `confirm` when the app set nothing; absent for a link.\n */\n readonly agent?: 'allow' | 'confirm' | 'deny';\n /** Only for a link. */\n readonly href?: string;\n /** Only for a form. */\n readonly fields?: readonly FormFieldEntry[];\n /**\n * Set when the last submit stopped on the form as a whole; only for a form. A fixed phrase when\n * the form's own `validate` said so, for the same reason as a field's `error`.\n */\n readonly error?: string | null;\n};\n\n/**\n * A notification's operation, without its attempt token.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type OperationEntry = {\n readonly status: OperationStatus;\n readonly attempt: number;\n readonly canCancel: boolean;\n readonly canRetry: boolean;\n readonly cancelRequested: boolean;\n};\n\n/**\n * One notification, in presentation order.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport type NotificationEntry = {\n readonly ref: string;\n readonly component: 'notification';\n /** `dismiss`, `show` (with a mounted `Toaster`), `press`, `fill`, `submit`, `cancel`, `retry`, by state. */\n readonly actions: readonly string[];\n /** The title. */\n readonly label: string;\n /** The description as text; for rich content, its announcement. */\n readonly text: string | null;\n readonly kind: NotificationKind;\n readonly priority: Priority;\n readonly occurrences: number;\n readonly location: NotificationLocation;\n readonly remainingMs: number | null;\n readonly pauseReasons: readonly PauseReason[];\n readonly progress: { readonly kind: 'indeterminate' | 'determinate'; readonly value: number | null; readonly label: string | null } | null;\n readonly draft: boolean;\n readonly operation: OperationEntry | null;\n readonly action: ActionEntry | null;\n};\n\n/** @experimental The protocol may change before the bridge reaches 1.0. */\nexport type ToasterAgentEntry = ToasterEntry | NotificationEntry;\n\n/**\n * What {@link toasterAgent} returns: pass it to the bridge's `connect`.\n *\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport interface ToasterAgent extends AgentComponentShape<ToasterAgentEntry> {\n /** The same frozen array until the controller changes; empty after `dispose`. */\n snapshot(): readonly ToasterAgentEntry[];\n /**\n * Calls `listener` after every change of the controller with what changed and who changed it.\n * On a notification's record: `present` (`true` when it appears, `false` when it closes, with\n * the close reason in `reason`), `content` (the app updated it; both values are null), `action`\n * (`idle`, `pending`, `failed`), `operation` (`pending`, `cancel-requested`, `fulfilled`,\n * `rejected`, `cancelled`) and `field:<name>` (who wrote the form field last: `app`, `user`,\n * `agent` or null; only when the author changes, and never the text). On the Toaster's record:\n * `island` (the `ref` of the notification it shows, or null) and `overflow` (the missed count\n * after it was acknowledged). `label` is the notification's title. The array is empty when the\n * snapshot changed with no author, such as a pause.\n */\n subscribe(listener: (changes?: readonly AgentChangeShape[]) => void): () => void;\n /** Whether a step is available now and the class it needs; no side effects. */\n readonly check: (step: AgentStepCallShape) => AgentStepCheckShape;\n /** Reads the controller again and runs the step, unless it changed since it was approved. */\n readonly run: (step: AgentStepCallShape, context: AgentRunContextShape) => AgentRunOutcomeShape | PromiseLike<AgentRunOutcomeShape>;\n /**\n * Opens the Island on the step's notification for a person, at once or once they stop using the\n * Toaster, without moving focus, and says which in `note`.\n */\n readonly summon: (step: AgentStepCallShape) => AgentSummonOutcomeShape;\n /** What each verb of the `toaster` and `notification` records does, for an agent. */\n readonly verbs: AgentVerbsShape;\n}\n\n/** @experimental The protocol may change before the bridge reaches 1.0. */\nexport interface ToasterAgentOptions {\n /** The component's name and the prefix of its refs; matches `[a-z][a-z0-9-]*`. Default `toaster`. */\n readonly name?: string;\n}\n\nconst freeze = Object.freeze;\nconst EMPTY: readonly never[] = freeze([]);\nconst quote = JSON.stringify;\nconst TOASTER_VERBS: ReadonlySet<string> = new Set(['open', 'close', 'clear', 'acknowledge']);\nconst NOTIFICATION_VERBS: ReadonlySet<string> = new Set(['dismiss', 'show', 'press', 'fill', 'submit', 'cancel', 'retry']);\n// For an agent that has never seen this code: arguments in order, what the step does, when it\n// needs a person. One entry for every verb a record can list.\nconst VERBS: AgentVerbsShape = freeze({\n toaster: freeze({\n open: 'No arguments. Opens the Island on the notification it shows first. Needs a mounted Toaster; refused while the person is using it.',\n close: 'No arguments. Closes the open Island; refused while it holds a form the person or an agent started filling.',\n clear: 'No arguments. Closes every notification at once.',\n acknowledge: 'No arguments. Marks the notifications that did not fit as seen: overflow.pending turns false.',\n }),\n notification: freeze({\n dismiss: 'No arguments. Closes this notification; its record leaves the snapshot.',\n show: 'No arguments. Opens the Island on this notification. Needs a mounted Toaster; refused while the person is using it.',\n press: 'No arguments. Runs the command action (action.kind \"command\") and waits for it: success closes the notification, result \"pending\" means it is still working. Under action.agent \"confirm\" it may need a person to approve. A link action has no verb: the bridge never opens it; its address is action.href.',\n fill: 'args [field name, text]: the field\\'s name from action.fields[].name, not its label, and a string. Writes the field as the agent; never over text the person typed.',\n submit: 'No arguments. Sends the form action (action.kind \"form\") and waits for it: success closes the notification, result \"pending\" means it is still working. Under action.agent \"confirm\" it may need a person to approve. A refusal names the fields that were not accepted.',\n cancel: 'No arguments. Asks the running operation to stop; result \"requested\".',\n retry: 'No arguments. Starts the failed operation again; result \"started\".',\n }),\n});\nconst STRICTNESS = { allow: 0, confirm: 1, deny: 2 } as const;\nconst DONE: AgentRunOutcomeShape = freeze({ status: 'done' });\nconst GONE: AgentRunOutcomeShape = freeze({ status: 'done', gone: true });\nconst STALE: AgentRunOutcomeShape = freeze({ status: 'stale' });\nconst UNAVAILABLE: AgentRunOutcomeShape = freeze({ status: 'unavailable' });\n\n// A form's `validate` and `errorMessage` see what the person typed and may quote it, so their\n// text stays with the person in the Island: an agent reads these instead.\nconst FORM_REJECTED = \"Not accepted by the form's own check\";\nconst FORM_FAILED = 'Action failed';\n\n// Refusals the adapter words itself; the bridge words the rest from the record's `actions`.\n// Labels and titles come from the app, so they are quoted.\nconst texts = {\n noScreen: (action: string) => `No Toaster is on screen: ${quote(action)} needs one.`,\n noArguments: (step: AgentStepCallShape) => `${quote(step.action)} on ${quote(step.ref)} takes no arguments.`,\n fillArguments: (step: AgentStepCallShape) => `${quote(step.action)} on ${quote(step.ref)} takes a field name and a value.`,\n noField: (step: AgentStepCallShape, name: string, names: readonly string[]) =>\n `No field ${quote(name)} on ${quote(step.ref)}. Fields: ${names.map((item) => quote(item)).join(', ')}.`,\n notText: (field: string) => `The value for ${quote(field)} must be a string.`,\n tooLong: (field: string, limit: number) => `${quote(field)} takes at most ${limit} characters.`,\n personTyped: (field: string) => `The person typed in ${quote(field)}. An agent can't overwrite it.`,\n notSent: (label: string, messages: string) => `${quote(label)} was not sent. ${messages}`,\n running: (label: string) => `${quote(label)} is already running.`,\n failed: (label: string, message: string) => `${quote(label)} failed: ${message}`,\n finished: 'This operation has already finished.',\n cancelRequested: 'Cancelling this operation was already requested.',\n notCancellable: \"This operation can't be cancelled.\",\n stillRunning: \"This operation is still running, so it can't be retried yet.\",\n notRetryable: \"This operation can't be retried.\",\n busy: 'The person is using the Island. Try again later.',\n islandOpen: 'The Island is open on it.',\n islandLater: 'The Island will open on it once they stop using it.',\n noToaster: 'No Toaster is on screen, so tell them what it does.',\n};\n\n/** A step as the adapter sees it right now: refused, or allowed under a class with a way to run it. */\ntype Plan =\n | { readonly available: false; readonly message?: string }\n | {\n readonly available: true;\n readonly permission: AgentPermissionShape;\n readonly names?: AgentStepNamesShape;\n /** The action object a press or a submit would run. */\n readonly subject?: object;\n readonly perform: (context: AgentRunContextShape) => AgentRunOutcomeShape | Promise<AgentRunOutcomeShape>;\n };\n\nconst NO_AUTHORS: FormReading['authors'] = new Map();\nconst NOT_AVAILABLE: Plan = freeze({ available: false });\nconst refuse = (message: string): Plan => freeze({ available: false, message });\nconst allowed = (perform: () => AgentRunOutcomeShape): Plan => freeze({ available: true, permission: 'allow', perform });\ntype PortResult = { readonly status: string; readonly reason?: string };\n/** A port refusal after the plan said yes: the state changed in between, so the step is unavailable. */\nconst outcome = (result: PortResult, done: AgentRunOutcomeShape, words: Readonly<Record<string, string>> = {}): AgentRunOutcomeShape => {\n if (result.status !== 'rejected') return done;\n const message = result.reason === undefined ? undefined : words[result.reason];\n return message === undefined ? UNAVAILABLE : freeze({ status: 'unavailable', message });\n};\n\n/**\n * Lets an agent read and drive a controller through the kit's agent bridge:\n * `agent.connect(toasterAgent(controller))`. It touches no DOM, starts no timers, never takes the\n * host from a `Toaster` and never moves focus. Form values never reach the snapshot.\n *\n * Steps: `open`, `close`, `clear` and `acknowledge` on the Toaster record; `show`, `dismiss`,\n * `press`, `fill`, `submit`, `cancel` and `retry` on a notification. `open` and `show` need a\n * mounted `Toaster`. `press` and `submit` follow the action's `agent` marker; every other step is\n * allowed unless the bridge's `allow` says no. `fill` (`args: [name, value]`) writes a form field\n * as the agent, never over what the person typed, and makes a draft as typing does; the snapshot\n * says who wrote each field (`filledBy`), never what. A press or submit that needs a person opens\n * the Island on its notification for them: at once, or after the attention delay once they stop\n * using the Toaster. While they use it (hover, focus, a gesture, a draft in the open Island, the\n * agent's own included), `open` and `show` are refused, and so is `close` over a draft.\n *\n * @throws TypeError for a controller that this copy of `@cloudlet/toast` did not create.\n * @experimental The protocol may change before the bridge reaches 1.0.\n */\nexport function toasterAgent<Slot, Signal extends CancellationSignal>(\n controller: Omit<CloudletController<Slot, Signal>, 'track'>,\n options?: ToasterAgentOptions,\n): ToasterAgent {\n const name = options?.name ?? 'toaster';\n const port = createToasterPort<Slot>(controller);\n // A number per handle, so a closed notification's ref is never handed to another one.\n const refs = new WeakMap<NotificationHandle, string>();\n let issued = 0;\n const refOf = (handle: NotificationHandle): string => {\n let ref = refs.get(handle);\n if (ref === undefined) refs.set(handle, ref = `${name}:${++issued}`);\n return ref;\n };\n // What the last change records said about each open notification, kept while someone listens.\n type Known = {\n label: string | undefined;\n action: 'idle' | 'pending' | 'failed';\n operation: { readonly token: string; value: string } | null;\n authors: FormReading['authors'];\n };\n const known = new Map<NotificationHandle, Known>();\n let islandRef: string | null = null;\n // The revision `known` was read at; a commit up to it is already in there.\n let seeded = 0;\n // Each subscriber with the revision it read on subscribing: a commit up to it brings it nothing.\n type Listener = { readonly call: (changes?: readonly AgentChangeShape[]) => void; readonly from: number };\n const listeners = new Set<Listener>();\n let stop: (() => void) | undefined;\n let source: ToasterReading<Slot> | undefined;\n let entries: readonly ToasterAgentEntry[] = EMPTY;\n // The notifications of the current snapshot by ref, for steps.\n let targets: ReadonlyMap<string, { readonly item: NotificationSnapshot<Slot>; readonly entry: NotificationEntry }> = new Map();\n\n const snapshot = (): readonly ToasterAgentEntry[] => {\n const reading = port.read();\n if (reading === source) return entries;\n source = reading;\n const state = reading.controller;\n if (state.disposed) { targets = new Map(); return entries = EMPTY; }\n const byHandle = new Map(state.notifications.map((item) => [item.handle, item] as const));\n const island = state.island;\n const count = state.stack.length;\n const found = new Map<string, { readonly item: NotificationSnapshot<Slot>; readonly entry: NotificationEntry }>();\n // Refs are issued in presentation order, so the top notification gets the lower number.\n const notifications = state.stack.map((handle) => {\n const item = byHandle.get(handle)!;\n const entry = notification(item, refOf(handle), island.open && island.current === handle, reading.mounted, reading.forms.get(handle));\n found.set(entry.ref, { item, entry });\n return entry;\n });\n targets = found;\n const toaster: ToasterEntry = freeze({\n ref: name, component: 'toaster' as const,\n actions: freeze([\n ...(!island.open && count > 0 && reading.mounted ? ['open'] : []),\n ...(island.open ? ['close'] : []),\n ...(count > 0 ? ['clear'] : []),\n ...(state.overflow.pending ? ['acknowledge'] : []),\n ]),\n island: freeze({ open: island.open, current: island.current ? refOf(island.current) : null }),\n count,\n overflow: freeze({ count: state.overflow.count, pending: state.overflow.pending }),\n mounted: reading.mounted,\n });\n return entries = freeze([toaster, ...notifications]);\n };\n\n /** Reads the step against the controller as it is now; `check` and `run` both start here. */\n const plan = (step: AgentStepCallShape): Plan => {\n const current = snapshot();\n const mounted = source?.mounted ?? false;\n const { action } = step;\n if (step.ref === name && current.length) {\n if (!TOASTER_VERBS.has(action)) return NOT_AVAILABLE;\n if (step.args.length) return refuse(texts.noArguments(step));\n if (action === 'open' && !mounted) return refuse(texts.noScreen(action));\n if (!current[0]!.actions.includes(action)) return NOT_AVAILABLE;\n // A busy person is not interrupted; only a draft stops `close`, which a person's Escape would collapse.\n if (action === 'open' && source!.busy) return refuse(texts.busy);\n if (action === 'close' && holdsDraft()) return refuse(texts.busy);\n switch (action) {\n case 'open': return allowed(() => outcome(port.open(), DONE, { 'no-host': texts.noScreen(action), busy: texts.busy }));\n case 'close': return allowed(() => outcome(port.close(), DONE, { busy: texts.busy }));\n case 'clear': return allowed(() => outcome(port.clear(), DONE));\n default: return allowed(() => outcome(port.acknowledge(), DONE));\n }\n }\n const target = targets.get(step.ref);\n if (!target || !NOTIFICATION_VERBS.has(action)) return NOT_AVAILABLE;\n const { item, entry } = target;\n if (action === 'fill') return fillPlan(step, item);\n if (step.args.length) return refuse(texts.noArguments(step));\n const { handle } = item;\n switch (action) {\n case 'show':\n if (!mounted) return refuse(texts.noScreen(action));\n break;\n case 'press': {\n const command = item.content.action;\n return command?.kind === 'command' ? pressPlan(item, command) : NOT_AVAILABLE;\n }\n case 'submit': {\n const form = item.content.action;\n return form?.kind === 'form' ? pressPlan(item, form) : NOT_AVAILABLE;\n }\n case 'cancel': {\n const operation = item.operation;\n if (!operation) return NOT_AVAILABLE;\n if (operation.status !== 'pending') return refuse(texts.finished);\n if (operation.cancelRequested) return refuse(texts.cancelRequested);\n if (!operation.canCancel) return refuse(texts.notCancellable);\n break;\n }\n case 'retry': {\n const operation = item.operation;\n if (!operation) return NOT_AVAILABLE;\n if (operation.status === 'pending') return refuse(texts.stillRunning);\n if (!operation.canRetry) return refuse(texts.notRetryable);\n break;\n }\n }\n if (!entry.actions.includes(action)) return NOT_AVAILABLE;\n if (action === 'show' && source!.busy) return refuse(texts.busy);\n switch (action) {\n case 'show': return allowed(() => outcome(port.show(handle), DONE, { 'no-host': texts.noScreen(action), busy: texts.busy }));\n case 'dismiss': return allowed(() => outcome(port.dismiss(handle), GONE));\n case 'cancel': return allowed(() => {\n const result = port.cancel(handle);\n return result.status === 'requested' ? freeze({ status: 'done', result: 'requested' })\n : outcome(result.status === 'unchanged' ? { status: 'rejected', reason: result.reason } : result, DONE, {\n settled: texts.finished, 'already-requested': texts.cancelRequested, 'not-cancellable': texts.notCancellable,\n });\n });\n default: return allowed(() => outcome(port.retry(handle), freeze({ status: 'done', result: 'started' }), {\n 'already-pending': texts.stillRunning, 'not-retryable': texts.notRetryable,\n }));\n }\n };\n\n /** The open Island shows a notification whose form holds a draft. */\n const holdsDraft = (): boolean => {\n const state = source!.controller;\n const current = state.island.current;\n return current !== null && state.notifications.some((item) => item.handle === current && item.draft);\n };\n\n // An agent's value goes in like a person's keystrokes, except over what the person typed. The\n // step's text names the field, never a value.\n const fillPlan = (step: AgentStepCallShape, item: NotificationSnapshot<Slot>): Plan => {\n const form = item.content.action;\n if (form?.kind !== 'form') return NOT_AVAILABLE;\n const [name, value] = step.args;\n if (step.args.length !== 2 || typeof name !== 'string') return refuse(texts.fillArguments(step));\n const field = form.fields.find((candidate) => candidate.name === name);\n if (!field) return refuse(texts.noField(step, name, form.fields.map((candidate) => candidate.name)));\n if (typeof value !== 'string') return refuse(texts.notText(field.label));\n const words = {\n 'already-pending': texts.running(form.label),\n 'too-long': texts.tooLong(field.label, field.maxLength ?? 0),\n 'person-typed': texts.personTyped(field.label),\n };\n if (item.action.status === 'pending') return refuse(words['already-pending']);\n if (field.maxLength !== undefined && value.length > field.maxLength) return refuse(words['too-long']);\n if (source!.forms.get(item.handle)?.authors.get(name) === 'user') return refuse(words['person-typed']);\n return allowed(() => outcome(port.fill(item.handle, name, value), DONE, words));\n };\n\n /** A command's press or a form's submit: both follow the action's marker and wait for its run. */\n const pressPlan = (item: NotificationSnapshot<Slot>, action: CommandAction | FormAction): Plan => {\n const { label } = action;\n const permission = action.agent ?? 'confirm';\n const names = freeze({ target: label, within: item.content.title });\n // A denied press never runs, so it is reported before its state.\n if (permission !== 'deny' && item.action.status === 'pending') return refuse(texts.running(label));\n return freeze({\n available: true, permission, names, subject: action,\n async perform({ signal, approved }: AgentRunContextShape): Promise<AgentRunOutcomeShape> {\n const started = port.press(item.handle, approved, signal);\n if (!(started instanceof Promise)) {\n return started.reason === 'stale' ? STALE : outcome(started, DONE, { 'already-pending': texts.running(label) });\n }\n const ended = await started;\n if (ended.status === 'done') return GONE;\n if (ended.status === 'replaced') return STALE;\n if (ended.status === 'failed') return freeze({ status: 'failed', message: texts.failed(label, action.kind === 'form' ? FORM_FAILED : ended.message) });\n if (ended.status === 'invalid') return freeze({ status: 'failed', message: texts.notSent(label, describe(action as FormAction, ended.errors)) });\n return freeze({ status: 'done', result: 'pending', ...(ended.gone ? { gone: true } : {}) });\n },\n });\n };\n\n // What a checked press or submit would have run, by step object: the bridge approves a step by\n // its ref and verb, so the action it named to the app or the person is held here until it runs.\n const checked = new WeakMap<AgentStepCallShape, object>();\n\n const check = (step: AgentStepCallShape): AgentStepCheckShape => {\n const verdict = plan(step);\n if (!verdict.available) return verdict;\n if (verdict.subject) checked.set(step, verdict.subject);\n return freeze({ available: true, permission: verdict.permission, ...(verdict.names ? { names: verdict.names } : {}) });\n };\n\n // The bridge approved the step under `approved`; the controller is read again before anything runs.\n const run = (step: AgentStepCallShape, context: AgentRunContextShape): AgentRunOutcomeShape | Promise<AgentRunOutcomeShape> => {\n const verdict = plan(step);\n if (!verdict.available) return verdict.message === undefined ? UNAVAILABLE : freeze({ status: 'unavailable', message: verdict.message });\n if (STRICTNESS[verdict.permission] > STRICTNESS[context.approved]) return STALE;\n // The app replaced the action while the step waited: the approval was for the other one.\n const subject = checked.get(step);\n if (subject !== undefined && subject !== verdict.subject) return STALE;\n return verdict.perform(context);\n };\n\n // A step only a person may take: the Island opens on its notification for them, through the\n // attention queue, so a person busy with the Toaster is not interrupted.\n const summon = (step: AgentStepCallShape): AgentSummonOutcomeShape => {\n snapshot();\n const target = targets.get(step.ref);\n if (!target) return false;\n const result = port.summon(target.item.handle);\n if (result.status === 'rejected') return result.reason === 'no-host' ? freeze({ reached: false, note: texts.noToaster }) : false;\n return freeze({ reached: true, note: result.status === 'waiting' ? texts.islandLater : texts.islandOpen });\n };\n\n /**\n * The records of one committed change: its events in order, then what only the state shows (an\n * action back to idle, a field's new author, the Island). A form's values are never read here.\n */\n const collect = (commit: PortCommit<Slot>): readonly AgentChangeShape[] => {\n // The commit's own state, not the latest: a listener before this one may have committed again.\n const state = commit.controller;\n // Subscribed while this commit was still queued: what it did was read then.\n if (state.revision <= seeded) return EMPTY;\n const { events } = commit;\n const live = new Map(state.notifications.map((item) => [item.handle, item] as const));\n for (const [handle, entry] of known) {\n const item = live.get(handle);\n if (item) entry.label = item.content.title;\n }\n const changes: AgentChangeShape[] = [];\n // Who changed a notification's content in this commit: the author of what follows from it.\n const touched = new Map<NotificationHandle, ChangeSource>();\n const push = (handle: NotificationHandle, key: string, value: AgentValueShape, previous: AgentValueShape, by: ChangeSource, reason?: string): void => {\n const label = known.get(handle)?.label;\n changes.push(freeze({\n ref: refOf(handle), component: 'notification', ...(label === undefined ? {} : { label }), key, value, previous,\n ...(reason === undefined ? {} : { reason }), source: by,\n }));\n };\n for (const event of events) {\n switch (event.type) {\n case 'admitted': {\n // The number is issued here, so a notification closed before anyone reads still has one.\n refOf(event.handle);\n known.set(event.handle, {\n label: live.get(event.handle)?.content.title, action: 'idle', operation: null,\n authors: commit.authors.get(event.handle) ?? NO_AUTHORS,\n });\n push(event.handle, 'present', true, false, event.source);\n break;\n }\n case 'closed':\n push(event.handle, 'present', false, true, event.source, event.reason);\n known.delete(event.handle);\n break;\n case 'updated':\n touched.set(event.handle, event.source);\n push(event.handle, 'content', null, null, event.source);\n break;\n case 'action-started':\n case 'action-failed': {\n const entry = known.get(event.handle);\n if (!entry) break;\n const next = event.type === 'action-started' ? 'pending' : 'failed';\n push(event.handle, 'action', next, entry.action, event.source);\n entry.action = next;\n break;\n }\n case 'operation-started': {\n const entry = event.handle && known.get(event.handle);\n if (!entry) break;\n touched.set(event.handle!, event.source);\n push(event.handle!, 'operation', 'pending', entry.operation?.value ?? null, event.source);\n entry.operation = { token: event.token, value: 'pending' };\n break;\n }\n case 'cancellation-requested':\n case 'operation-settled': {\n const entry = event.handle && known.get(event.handle);\n // An attempt that a newer one replaced no longer speaks for the notification.\n if (!entry || entry.operation?.token !== event.token) break;\n if (event.type === 'operation-settled') touched.set(event.handle!, event.source);\n const next = event.type === 'operation-settled' ? event.status : 'cancel-requested';\n push(event.handle!, 'operation', next, entry.operation.value, event.source);\n entry.operation.value = next;\n break;\n }\n case 'overflow-acknowledged':\n changes.push(freeze({ ref: name, component: 'toaster', key: 'overflow', value: 0, previous: event.count, source: event.source }));\n break;\n }\n }\n for (const [handle, entry] of known) {\n // A notification missing here closed in a later commit; its own records follow.\n const item = live.get(handle);\n if (!item) continue;\n const by = touched.get(handle);\n if (item.action.status === 'idle' && entry.action !== 'idle') {\n push(handle, 'action', 'idle', entry.action, by ?? 'system');\n entry.action = 'idle';\n }\n const authors = commit.authors.get(handle) ?? NO_AUTHORS;\n if (authors !== entry.authors) {\n // In the form's own order; a field of the form that was replaced comes after them.\n const action = item.content.action;\n const names = action?.kind === 'form' ? action.fields.map((field) => field.name) : [];\n for (const field of new Set([...names, ...entry.authors.keys(), ...authors.keys()])) {\n const next = authors.get(field) ?? null;\n const previous = entry.authors.get(field) ?? null;\n // A new author is the source; a field emptied with its form was replaced by the app.\n if (next !== previous) push(handle, `field:${field}`, next, previous, next ?? by ?? 'app');\n }\n entry.authors = authors;\n }\n }\n const current = state.island.current ? refOf(state.island.current) : null;\n if (current !== islandRef) {\n changes.push(freeze({\n ref: name, component: 'toaster', key: 'island', value: current, previous: islandRef,\n source: state.island.source ?? commit.closedBy ?? 'system',\n }));\n islandRef = current;\n }\n return freeze(changes);\n };\n\n const subscribe = (listener: (changes?: readonly AgentChangeShape[]) => void): (() => void) => {\n // The same function may subscribe twice; each subscription is removed on its own.\n let own: Listener;\n if (!listeners.size) {\n // Refs of what is already there are issued as a snapshot does, top first.\n snapshot();\n const reading = port.read();\n const state = reading.controller;\n known.clear();\n for (const item of state.notifications) {\n const operation = item.operation;\n known.set(item.handle, {\n label: item.content.title, action: item.action.status,\n operation: operation ? { token: operation.token, value: operation.status === 'pending' && operation.cancelRequested ? 'cancel-requested' : operation.status } : null,\n authors: reading.forms.get(item.handle)?.authors ?? NO_AUTHORS,\n });\n }\n islandRef = state.island.current ? refOf(state.island.current) : null;\n seeded = state.revision;\n own = { call: listener, from: seeded };\n stop = port.subscribe((commit) => {\n const changes = collect(commit);\n const revision = commit.controller.revision;\n // Every listener hears the change, and each error goes on to the controller's diagnostics.\n for (const each of [...listeners]) {\n if (!listeners.has(each)) continue;\n // One that subscribed while this commit was queued read what it did on subscribing.\n try { each.call(revision <= each.from ? EMPTY : changes); } catch (error) { port.report(error); }\n }\n });\n } else {\n own = { call: listener, from: port.read().controller.revision };\n }\n listeners.add(own);\n return () => {\n if (!listeners.delete(own) || listeners.size) return;\n stop?.();\n stop = undefined;\n known.clear();\n };\n };\n\n return freeze({ protocol: 1 as const, name, snapshot, subscribe, check, run, summon, verbs: VERBS });\n}\n\n/**\n * Why a form was not sent, by field label and never with a value: the built-in messages as the\n * person sees them, and for the app's own `validate` only which fields it did not accept.\n */\nfunction describe(form: FormAction, errors: FormErrors): string {\n if (errors.broken) return `${FORM_FAILED}.`;\n if (errors.authored) {\n // Own keys only, as below.\n const labels = form.fields.flatMap((field) => Object.hasOwn(errors.fields, field.name) ? [quote(field.label)] : []);\n return `The form's own check did not accept ${labels.length ? labels.join(', ') : 'it'}.`;\n }\n const sentence = (message: string) => /[.!?]$/.test(message.trim()) ? message.trim() : `${message.trim()}.`;\n return [\n // Own keys only: a field named `constructor` must not read `Object.prototype`.\n ...form.fields.flatMap((field) => Object.hasOwn(errors.fields, field.name) ? [`${quote(field.label)}: ${sentence(errors.fields[field.name]!)}`] : []),\n ...(errors.form ? [sentence(errors.form)] : []),\n ].join(' ');\n}\n\nfunction notification<Slot>(item: NotificationSnapshot<Slot>, ref: string, shown: boolean, mounted: boolean, form: FormReading | undefined): NotificationEntry {\n const { content } = item;\n const description = content.description;\n const progress = content.progress;\n const operation = item.operation;\n const action = actionEntry(item, form);\n // `deny` stops pressing and submitting only: a person can still submit what an agent filled.\n const ready = item.action.status !== 'pending';\n const may = ready && action?.agent !== 'deny';\n return freeze({\n ref, component: 'notification' as const,\n actions: freeze([\n 'dismiss',\n ...(!shown && mounted ? ['show'] : []),\n ...(action?.kind === 'command' && may ? ['press'] : []),\n ...(action?.kind === 'form' && ready ? ['fill'] : []),\n ...(action?.kind === 'form' && may ? ['submit'] : []),\n ...(operation?.canCancel ? ['cancel'] : []),\n ...(operation?.canRetry ? ['retry'] : []),\n ]),\n label: content.title,\n text: description ? description.kind === 'text' ? description.text : description.announcement : null,\n kind: item.kind,\n priority: item.priority,\n occurrences: item.occurrences,\n location: item.location,\n remainingMs: item.remainingMs,\n pauseReasons: freeze([...item.pauseReasons]),\n progress: progress ? freeze({\n kind: progress.kind,\n value: progress.kind === 'determinate' ? progress.value : null,\n label: progress.label ?? null,\n }) : null,\n draft: item.draft,\n operation: operation ? freeze({\n status: operation.status, attempt: operation.attempt, canCancel: operation.canCancel,\n canRetry: operation.canRetry, cancelRequested: operation.cancelRequested,\n }) : null,\n action,\n });\n}\n\nfunction actionEntry<Slot>(item: NotificationSnapshot<Slot>, form: FormReading | undefined): ActionEntry | null {\n const action = item.content.action;\n if (!action) return null;\n const state = item.action;\n const common = {\n kind: action.kind, label: action.label, status: state.status,\n message: state.status !== 'failed' ? null : action.kind === 'form' ? FORM_FAILED : state.message,\n };\n if (action.kind === 'link') return freeze({ ...common, href: action.href });\n if (action.kind === 'command') return freeze({ ...common, agent: action.agent ?? 'confirm' });\n const errors = form?.errors;\n return freeze({\n ...common,\n agent: action.agent ?? 'confirm',\n fields: freeze(action.fields.map((field) => freeze({\n name: field.name, label: field.label, kind: field.kind, required: field.required ?? false,\n maxLength: field.maxLength ?? null, inputMode: field.inputMode ?? null,\n filled: form?.filled.has(field.name) ?? false,\n filledBy: form?.authors.get(field.name) ?? null,\n // Own keys only: a field named `constructor` must not read `Object.prototype`.\n error: errors && Object.hasOwn(errors.fields, field.name) ? errors.authored ? FORM_REJECTED : errors.fields[field.name]! : null,\n }))),\n error: errors?.form ? errors.broken ? FORM_FAILED : errors.authored ? FORM_REJECTED : errors.form : null,\n });\n}\n"],"mappings":";;AA0TA,IAAMA,IAAS,OAAO,QAChBC,IAA0BD,EAAO,CAAC,CAAC,GACnCE,IAAQ,KAAK,WACbC,oBAAqC,IAAI,IAAI;CAAC;CAAQ;CAAS;CAAS;AAAa,CAAC,GACtFC,oBAA0C,IAAI,IAAI;CAAC;CAAW;CAAQ;CAAS;CAAQ;CAAU;CAAU;AAAO,CAAC,GAGnHC,IAAyBL,EAAO;CACpC,SAASA,EAAO;EACd,MAAM;EACN,OAAO;EACP,OAAO;EACP,aAAa;CACf,CAAC;CACD,cAAcA,EAAO;EACnB,SAAS;EACT,MAAM;EACN,OAAO;EACP,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,OAAO;CACT,CAAC;AACH,CAAC,GACKM,IAAa;CAAE,OAAO;CAAG,SAAS;CAAG,MAAM;AAAE,GAC7CC,IAA6BP,EAAO,EAAE,QAAQ,OAAO,CAAC,GACtDQ,IAA6BR,EAAO;CAAE,QAAQ;CAAQ,MAAM;AAAK,CAAC,GAClES,IAA8BT,EAAO,EAAE,QAAQ,QAAQ,CAAC,GACxDU,IAAoCV,EAAO,EAAE,QAAQ,cAAc,CAAC,GAIpEW,IAAgB,wCAChBC,IAAc,i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AS3F,IAAc2F,EAAO,WAAW5F,IAAgB4F,EAAO,OAAO;CACtG,CAAC;AACH"}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import type { CloudletSpring, CloudletTimedSpring } from './react.js';
|
|
3
|
+
/** A button of a notification; a press calls `onAction(item.id, action.id)`. */
|
|
4
|
+
export interface NotificationItemAction {
|
|
5
|
+
/** Unique among the notification's actions. */
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly label: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* One notification of the app's list. The app owns the list: it loads it from wherever it likes (a
|
|
11
|
+
* REST endpoint, a WebSocket, local state) and gives the center a new array whenever it changes;
|
|
12
|
+
* the center never changes it itself.
|
|
13
|
+
*/
|
|
14
|
+
export interface NotificationItem {
|
|
15
|
+
/** Stable and unique in the list: the center follows a notification by its id across arrays. */
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly title: ReactNode;
|
|
18
|
+
readonly description?: ReactNode;
|
|
19
|
+
/** When it happened: a `Date` or milliseconds since the epoch. The list shows the newest first. */
|
|
20
|
+
readonly time: Date | number;
|
|
21
|
+
/** Notifications with the same nonempty `group` stack into one group; without it one stands alone. */
|
|
22
|
+
readonly group?: string;
|
|
23
|
+
/**
|
|
24
|
+
* `success`, `error`, `info`, `warning` or `loading` draw the Toaster's status icon and tint; any
|
|
25
|
+
* other string is the app's own kind (`data-kind` on the card) and draws no icon of its own.
|
|
26
|
+
*/
|
|
27
|
+
readonly kind?: string;
|
|
28
|
+
/** `false` marks the notification unread (`data-read="false"` and a dot); omitted, it reads as read. */
|
|
29
|
+
readonly read?: boolean;
|
|
30
|
+
/** Replaces the kind's icon. */
|
|
31
|
+
readonly icon?: ReactNode;
|
|
32
|
+
readonly actions?: readonly NotificationItemAction[];
|
|
33
|
+
/** The app's own data, passed back untouched in `renderNotification`. */
|
|
34
|
+
readonly data?: unknown;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The parts of the default card, for `renderNotification` to place as it likes. The center keeps
|
|
38
|
+
* the card's frame (`li`, its motion and swipe); what the function returns is its content.
|
|
39
|
+
*/
|
|
40
|
+
export interface NotificationParts {
|
|
41
|
+
/** The status icon or `item.icon`; null without either. */
|
|
42
|
+
readonly icon: ReactNode;
|
|
43
|
+
/** The title as the card's heading, with `titleId`. */
|
|
44
|
+
readonly title: ReactElement;
|
|
45
|
+
/** The description in its part; null without one. */
|
|
46
|
+
readonly description: ReactNode;
|
|
47
|
+
/** The action buttons in their row; null without actions. */
|
|
48
|
+
readonly actions: ReactNode;
|
|
49
|
+
/**
|
|
50
|
+
* The time and, in its place on hover and focus, the clear button. Leave it out and the card has
|
|
51
|
+
* no clear button: it still clears by swipe and with its group.
|
|
52
|
+
*/
|
|
53
|
+
readonly time: ReactElement;
|
|
54
|
+
/** The id of the title's heading, for the app's own `aria-labelledby`. */
|
|
55
|
+
readonly titleId: string;
|
|
56
|
+
/** Asks the app to dismiss this notification, as its clear button does (`onDismiss`). */
|
|
57
|
+
readonly dismiss: () => void;
|
|
58
|
+
/** Runs an action of this notification, as its button does (`onAction`). */
|
|
59
|
+
readonly action: (actionId: string) => void;
|
|
60
|
+
/** The default content: the head (icon, title, time) and the body (description, actions). */
|
|
61
|
+
readonly content: ReactElement;
|
|
62
|
+
}
|
|
63
|
+
export interface NotificationCenterLabels {
|
|
64
|
+
/** The panel's visible heading and accessible name, "Notifications" by default. */
|
|
65
|
+
readonly title: string;
|
|
66
|
+
/** The panel's close button. */
|
|
67
|
+
readonly close: string;
|
|
68
|
+
/** The button that clears one card, in place of its time. */
|
|
69
|
+
readonly clear: string;
|
|
70
|
+
/** The line of an open center without notifications. */
|
|
71
|
+
readonly empty: string;
|
|
72
|
+
/** The hidden word before a card's title that tells a screen reader its kind; an empty string says nothing. */
|
|
73
|
+
readonly kind: (kind: string) => string;
|
|
74
|
+
/** The hidden word before the title of an unread notification, "Unread" by default. */
|
|
75
|
+
readonly unread: string;
|
|
76
|
+
/** A card's time: `time` and `now` are milliseconds since the epoch. "now", "2m", "1h", "3d", then a date, by default. */
|
|
77
|
+
readonly time: (time: number, now: number) => string;
|
|
78
|
+
/** A group's name from its key (the notifications' `group`): the key as it is by default. */
|
|
79
|
+
readonly group: (key: string) => string;
|
|
80
|
+
/** The button under a collapsed stack that expands it: "Deploys · 2 more" by default; `count` is the notifications under the top one. */
|
|
81
|
+
readonly more: (label: string, count: number) => string;
|
|
82
|
+
/** The accessible name of a group of `count` notifications: "Deploys, 3 notifications" by default. */
|
|
83
|
+
readonly stack: (label: string, count: number) => string;
|
|
84
|
+
/** The button that collapses an expanded group, beside its name. */
|
|
85
|
+
readonly showLess: string;
|
|
86
|
+
/** The two-step button in an expanded group's heading row that clears the group: "Clear" by default. */
|
|
87
|
+
readonly clearGroup: string;
|
|
88
|
+
/** The same button armed, and the polite status then: "Clear 3" by default; `count` is the group's notifications. */
|
|
89
|
+
readonly clearGroupConfirm: (count: number) => string;
|
|
90
|
+
/**
|
|
91
|
+
* The accessible name of a collapsed stack's clear button, in place of its top card's time: "Clear
|
|
92
|
+
* Deploys" by default. Armed, it reads `clearGroupConfirm`.
|
|
93
|
+
*/
|
|
94
|
+
readonly clearStack: (label: string) => string;
|
|
95
|
+
/** The two-step button in the panel's header that clears every notification, shown from two: "Clear all" by default. */
|
|
96
|
+
readonly clearAll: string;
|
|
97
|
+
/** The same button armed, and the polite status then: "Clear 5" by default; `count` is every notification of the list. */
|
|
98
|
+
readonly clearAllConfirm: (count: number) => string;
|
|
99
|
+
}
|
|
100
|
+
/** Styling hooks of the notification center; see `NotificationCenterProps.classNames`. */
|
|
101
|
+
export type NotificationCenterPart = 'center' | 'header' | 'heading' | 'dismiss' | 'list' | 'card' | 'time' | 'clear' | 'empty' | 'group' | 'group-header' | 'group-title' | 'show-less' | 'group-list' | 'edge' | 'more' | 'clear-all' | 'group-clear' | 'stack-clear' | 'icon' | 'title' | 'body' | 'description' | 'actions' | 'action' | 'unread';
|
|
102
|
+
/**
|
|
103
|
+
* The notification center's motion constants: durations in ms at `timeScale: 1`, offsets and blur
|
|
104
|
+
* in CSS px. Reported by the laboratory's tuning panel; see `NotificationCenterMotion.overrides`.
|
|
105
|
+
*/
|
|
106
|
+
export interface NotificationCenterMotionConstants {
|
|
107
|
+
/** The drawer's position spring opening. */
|
|
108
|
+
readonly open: CloudletSpring;
|
|
109
|
+
/** The drawer's position spring closing. */
|
|
110
|
+
readonly close: CloudletSpring;
|
|
111
|
+
/** How far past the column's width a closed card lies, in px. */
|
|
112
|
+
readonly travel: number;
|
|
113
|
+
/** The share of the way each next card trails the previous one by (0.12 = 12 %), up to the eighth card. */
|
|
114
|
+
readonly lag: number;
|
|
115
|
+
/** A card arriving in the open center: scale from `scale` on the spring, opacity over `fade` ms. */
|
|
116
|
+
readonly enter: CloudletTimedSpring & {
|
|
117
|
+
readonly scale: number;
|
|
118
|
+
readonly fade: number;
|
|
119
|
+
};
|
|
120
|
+
/** A card leaving the list. */
|
|
121
|
+
readonly exit: CloudletTimedSpring;
|
|
122
|
+
/** The other cards moving to their new places. */
|
|
123
|
+
readonly reflow: CloudletSpring;
|
|
124
|
+
/** The time and the clear button in its place: swap duration and blur radius in px. */
|
|
125
|
+
readonly swap: number;
|
|
126
|
+
readonly swapBlur: number;
|
|
127
|
+
/** Reduced motion: opening, closing and the list change opacity only, for this long. */
|
|
128
|
+
readonly reduced: number;
|
|
129
|
+
/**
|
|
130
|
+
* A group of two notifications or more. Collapsed, up to two edges lie under its top card, each
|
|
131
|
+
* `step` px lower than the one above and narrower by `shrink` of the card's width (0.06 = 6 %, so
|
|
132
|
+
* 0.94 and 0.88). Its cards move between the stack and the list on `expand` and `collapse`; an
|
|
133
|
+
* edge's content shows over `reveal` ms from a `blur` px blur, as the group's heading row and the
|
|
134
|
+
* button under the stack swap; the n-th card of the group starts once the first has covered
|
|
135
|
+
* n × `cascade` of its way (0.06 = 6 % per card, up to the eighth; 0 moves them together).
|
|
136
|
+
*/
|
|
137
|
+
readonly stack: {
|
|
138
|
+
readonly expand: CloudletSpring;
|
|
139
|
+
readonly collapse: CloudletSpring;
|
|
140
|
+
readonly step: number;
|
|
141
|
+
readonly shrink: number;
|
|
142
|
+
readonly reveal: number;
|
|
143
|
+
readonly blur: number;
|
|
144
|
+
readonly cascade: number;
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The notification center's backdrop constants for `backdrop="blur"`; see
|
|
149
|
+
* `NotificationCenterMotion.overrides`. `layers` is how many blur layers stand under the tone: from
|
|
150
|
+
* the strongest (`--cloudlet-center-blur`, at the edge) each next one, nearer the column's inner
|
|
151
|
+
* side, has half the radius; one layer is a single blur of 0.7 × `--cloudlet-center-blur` fading in
|
|
152
|
+
* from the band's inner edge. Without an override, an Apple engine (`navigator.vendor`) gets one.
|
|
153
|
+
* `scrollTint` shows the tone alone while the page scrolls under the open center: a scroll anywhere
|
|
154
|
+
* in the document but the panel's own list fades the blur layers out over 120 ms, and 150 ms without
|
|
155
|
+
* one fades them back (at once under reduced motion).
|
|
156
|
+
*/
|
|
157
|
+
export interface NotificationCenterBackdropConstants {
|
|
158
|
+
/** An integer from 1 to 8; 4 by default. */
|
|
159
|
+
readonly layers: number;
|
|
160
|
+
/** `false` by default. */
|
|
161
|
+
readonly scrollTint: boolean;
|
|
162
|
+
}
|
|
163
|
+
type PartialMotion<T> = {
|
|
164
|
+
readonly [K in keyof T]?: T[K] extends number ? number : PartialMotion<T[K]>;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Partial `NotificationCenterMotionConstants`; nested springs and the stack's fields may be partial
|
|
168
|
+
* too. `backdrop` takes `NotificationCenterBackdropConstants` fields: `layers` an integer from 1 to
|
|
169
|
+
* 8, `scrollTint` a boolean; any other value keeps the default.
|
|
170
|
+
*/
|
|
171
|
+
export type NotificationCenterMotionOverrides = PartialMotion<NotificationCenterMotionConstants> & {
|
|
172
|
+
readonly backdrop?: Partial<NotificationCenterBackdropConstants>;
|
|
173
|
+
};
|
|
174
|
+
export interface NotificationCenterMotion {
|
|
175
|
+
/**
|
|
176
|
+
* Debugging and laboratory aid: slows every transition (0.5 = twice as slow).
|
|
177
|
+
* Default 1; a non-finite or nonpositive value falls back to 1. Not recommended in production.
|
|
178
|
+
*/
|
|
179
|
+
readonly timeScale?: number;
|
|
180
|
+
/**
|
|
181
|
+
* Debugging and laboratory channel: replaces the motion constants live, for transitions started
|
|
182
|
+
* after the change. A field that is not a finite number in range (stiffness and mass > 0, the rest
|
|
183
|
+
* ≥ 0) keeps its default. Not a styling API: the values may change between releases.
|
|
184
|
+
*/
|
|
185
|
+
readonly overrides?: NotificationCenterMotionOverrides;
|
|
186
|
+
}
|
|
187
|
+
/** Whether the center is open, uncontrolled or controlled; for `useNotificationCenter` and the panel. */
|
|
188
|
+
export interface NotificationCenterOpenOptions {
|
|
189
|
+
/** Controls the open state; pair it with `onOpenChange`. */
|
|
190
|
+
readonly open?: boolean | undefined;
|
|
191
|
+
/** The first open state of an uncontrolled center; `false` by default. */
|
|
192
|
+
readonly defaultOpen?: boolean | undefined;
|
|
193
|
+
/** Called with the next state when a trigger, Escape, a press outside, the close button or a swipe asks to open or close. */
|
|
194
|
+
readonly onOpenChange?: ((open: boolean) => void) | undefined;
|
|
195
|
+
}
|
|
196
|
+
export interface NotificationCenterProps extends NotificationCenterOpenOptions {
|
|
197
|
+
/**
|
|
198
|
+
* The center's open state and its triggers, from `useNotificationCenter()`. Without it the panel
|
|
199
|
+
* keeps its own state from `open`, `defaultOpen` and `onOpenChange`, and has no trigger of its own.
|
|
200
|
+
*/
|
|
201
|
+
readonly center?: UseNotificationCenterResult;
|
|
202
|
+
/**
|
|
203
|
+
* The app's notifications, in any order (the panel shows the newest first). Give a new array when
|
|
204
|
+
* it changes: the panel animates what arrived, left and moved. Of two with one id the first counts.
|
|
205
|
+
*/
|
|
206
|
+
readonly notifications: readonly NotificationItem[];
|
|
207
|
+
/**
|
|
208
|
+
* A card's clear button or a swipe asks to dismiss it. Without it a card has no clear button and
|
|
209
|
+
* does not swipe; with only `onClear`, these call `onClear([id])`.
|
|
210
|
+
*/
|
|
211
|
+
readonly onDismiss?: ((id: string) => void) | undefined;
|
|
212
|
+
/**
|
|
213
|
+
* A group's two-step Clear (its ids) or the header's Clear all (every id of the list) asks to clear
|
|
214
|
+
* these notifications. Without it the two-step buttons call `onDismiss` for each id, and with
|
|
215
|
+
* neither callback there are none.
|
|
216
|
+
*/
|
|
217
|
+
readonly onClear?: ((ids: readonly string[]) => void) | undefined;
|
|
218
|
+
/** A press of one of a notification's `actions`. The card stays: the app removes it if it wants. */
|
|
219
|
+
readonly onAction?: ((id: string, actionId: string) => void) | undefined;
|
|
220
|
+
/**
|
|
221
|
+
* Unread notifications (`read: false`) the person has seen: those listed when the panel opens and
|
|
222
|
+
* those that arrive while it is open (on a visible page), each id once per opening.
|
|
223
|
+
*/
|
|
224
|
+
readonly onRead?: ((ids: readonly string[]) => void) | undefined;
|
|
225
|
+
/** Draws a card's content from the default parts; the center keeps its frame, motion and swipe. */
|
|
226
|
+
readonly renderNotification?: ((item: NotificationItem, parts: NotificationParts) => ReactNode) | undefined;
|
|
227
|
+
/** Physical: the panel stays at that edge in RTL too. Default `right`. */
|
|
228
|
+
readonly side?: 'left' | 'right';
|
|
229
|
+
readonly theme?: 'system' | 'light' | 'dark';
|
|
230
|
+
readonly dir?: 'ltr' | 'rtl';
|
|
231
|
+
readonly labels?: Partial<NotificationCenterLabels>;
|
|
232
|
+
/** Extra classes per part, added to the own `cloudlet-*` classes (never replacing them). */
|
|
233
|
+
readonly classNames?: Partial<Record<NotificationCenterPart, string>>;
|
|
234
|
+
/**
|
|
235
|
+
* What lies under the panel's column and a band past it, at its edge: `blur` (the default: the
|
|
236
|
+
* page blurred progressively, strongest at the edge, under a tone of `--cloudlet-center-blur-tint`;
|
|
237
|
+
* one blur layer in Safari and other Apple engines; the tone of `tint` in a window narrower than
|
|
238
|
+
* 48rem and where `backdrop-filter` is unsupported), `tint` (a tone, `--cloudlet-center-tint` of
|
|
239
|
+
* `--cloudlet-background`, even under the column and fading out across the band) or `none` (nothing: the panel's header and
|
|
240
|
+
* empty line then stand on the page, whose contrast is the app's). Any other value is `blur`.
|
|
241
|
+
* Reduced transparency draws the tone of `tint` in place of `blur`: `data-reduced-transparency` on
|
|
242
|
+
* an ancestor of the panel (it is portalled into the body, so on `<body>` or `<html>`; by presence,
|
|
243
|
+
* live) and the system's `prefers-reduced-transparency: reduce`; an app cannot turn the blur on
|
|
244
|
+
* against the system. The panel's root says the app's result in `data-backdrop` (`tint` under the
|
|
245
|
+
* attribute; the system's setting is CSS and stays out of it), and with `blur` how many blur layers
|
|
246
|
+
* it has in `data-backdrop-layers`. Read on every render.
|
|
247
|
+
*/
|
|
248
|
+
readonly backdrop?: 'blur' | 'tint' | 'none';
|
|
249
|
+
/** Read on every render. */
|
|
250
|
+
readonly motion?: NotificationCenterMotion;
|
|
251
|
+
/**
|
|
252
|
+
* The app's own reduced-motion setting. `true` removes motion whatever the system says; `false`
|
|
253
|
+
* and omitting it follow the system and `data-reduced-motion` on an ancestor of the panel (it is
|
|
254
|
+
* portalled into the body, so on `<body>` or `<html>`; the attribute counts by presence). An app
|
|
255
|
+
* cannot turn motion on against the system's `prefers-reduced-motion: reduce`. Read on every render.
|
|
256
|
+
*/
|
|
257
|
+
readonly reducedMotion?: boolean;
|
|
258
|
+
/** The nonce of the panel's own `<style>`, whose CSSOM rules carry its motion under a strict CSP. Read when the panel opens. */
|
|
259
|
+
readonly nonce?: string;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Spread on the app's own button: it opens and closes the center. A center takes as many buttons
|
|
263
|
+
* as these props are spread on; focus returns to the one that opened it.
|
|
264
|
+
*/
|
|
265
|
+
export interface NotificationCenterTriggerProps {
|
|
266
|
+
/** Returns a cleanup for the element under React 19 and later, which call it in place of `null`. */
|
|
267
|
+
readonly ref: (element: HTMLElement | null) => (() => void) | undefined;
|
|
268
|
+
readonly 'aria-expanded': boolean;
|
|
269
|
+
/** The panel's id while it is open. */
|
|
270
|
+
readonly 'aria-controls': string | undefined;
|
|
271
|
+
readonly 'aria-haspopup': 'dialog';
|
|
272
|
+
readonly onClick: (event?: {
|
|
273
|
+
readonly currentTarget: EventTarget | null;
|
|
274
|
+
}) => void;
|
|
275
|
+
}
|
|
276
|
+
export interface UseNotificationCenterResult {
|
|
277
|
+
readonly open: boolean;
|
|
278
|
+
/** Opens or closes the center, as the app; a controlled center asks through `onOpenChange`. The same function every render. */
|
|
279
|
+
readonly setOpen: (open: boolean) => void;
|
|
280
|
+
readonly triggerProps: NotificationCenterTriggerProps;
|
|
281
|
+
}
|
|
282
|
+
/** Public component and hook signatures. */
|
|
283
|
+
export type NotificationCenterComponent = (props: NotificationCenterProps) => ReactElement | null;
|
|
284
|
+
export type UseNotificationCenter = (options?: NotificationCenterOpenOptions) => UseNotificationCenterResult;
|
|
285
|
+
export { NotificationCenter, useNotificationCenter } from './react/center.js';
|
|
286
|
+
//# sourceMappingURL=center-react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"center-react.d.ts","sourceRoot":"","sources":["../src/center-react.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAKtE,gFAAgF;AAChF,MAAM,WAAW,sBAAsB;IACrC,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gGAAgG;IAChG,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,WAAW,CAAC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
|
1
|
+
export { NotificationCenter, useNotificationCenter } from './center-react.js';
|
|
2
|
+
export type { NotificationCenterBackdropConstants, NotificationCenterComponent, NotificationCenterLabels, NotificationCenterMotion, NotificationCenterMotionConstants, NotificationCenterMotionOverrides, NotificationCenterOpenOptions, NotificationCenterPart, NotificationCenterProps, NotificationCenterTriggerProps, NotificationItem, NotificationItemAction, NotificationParts, UseNotificationCenter, UseNotificationCenterResult, } from './center-react.js';
|
|
3
|
+
//# sourceMappingURL=center.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"center.d.ts","sourceRoot":"","sources":["../src/center.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,YAAY,EACV,mCAAmC,EACnC,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,EACxB,iCAAiC,EACjC,iCAAiC,EACjC,6BAA6B,EAC7B,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EAC9B,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC"}
|