@saar-ai/web-widget 0.4.1 → 0.6.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/dist/card-aspect.d.ts +58 -0
- package/dist/card-aspect.d.ts.map +1 -0
- package/dist/chunks/chat-tMKkYmTC.js +592 -0
- package/dist/chunks/host-widget-C0XT9lHX.js +9637 -0
- package/dist/chunks/{telemetry-Bw-3F_Zk.js → telemetry-BI_SEWTb.js} +104 -2
- package/dist/dock/dock-caption.d.ts +67 -0
- package/dist/dock/dock-caption.d.ts.map +1 -0
- package/dist/dock/dock-motion.d.ts +155 -0
- package/dist/dock/dock-motion.d.ts.map +1 -0
- package/dist/dock/dock-pill.d.ts +38 -0
- package/dist/dock/dock-pill.d.ts.map +1 -0
- package/dist/dock/dock-row.d.ts +120 -0
- package/dist/dock/dock-row.d.ts.map +1 -0
- package/dist/dock/dock-sheet.d.ts +89 -0
- package/dist/dock/dock-sheet.d.ts.map +1 -0
- package/dist/dock/dock-shelf.d.ts +38 -0
- package/dist/dock/dock-shelf.d.ts.map +1 -0
- package/dist/dock/dock-state.d.ts +221 -0
- package/dist/dock/dock-state.d.ts.map +1 -0
- package/dist/dock/dock.d.ts +344 -0
- package/dist/dock/dock.d.ts.map +1 -0
- package/dist/dock/geometry.d.ts +161 -0
- package/dist/dock/geometry.d.ts.map +1 -0
- package/dist/format-money.d.ts +54 -17
- package/dist/format-money.d.ts.map +1 -1
- package/dist/generated/widget-css.d.ts.map +1 -1
- package/dist/host-widget.d.ts +156 -16
- package/dist/host-widget.d.ts.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4029 -7
- package/dist/messages.d.ts +86 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/next/index.js +1 -1
- package/dist/session-log.d.ts +7 -0
- package/dist/session-log.d.ts.map +1 -1
- package/dist/session-panel.d.ts +13 -3
- package/dist/session-panel.d.ts.map +1 -1
- package/dist/theme/color.d.ts +114 -0
- package/dist/theme/color.d.ts.map +1 -0
- package/dist/theme/derive.d.ts +92 -0
- package/dist/theme/derive.d.ts.map +1 -0
- package/dist/theme/index.d.ts +10 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/turn-order.d.ts +106 -0
- package/dist/turn-order.d.ts.map +1 -0
- package/dist/use-chat-session.d.ts +146 -17
- package/dist/use-chat-session.d.ts.map +1 -1
- package/dist/use-voice-session.d.ts +110 -4
- package/dist/use-voice-session.d.ts.map +1 -1
- package/dist/voice-widget.d.ts +114 -24
- package/dist/voice-widget.d.ts.map +1 -1
- package/dist/widget-cards.d.ts +28 -1
- package/dist/widget-cards.d.ts.map +1 -1
- package/dist/widget.css +1 -1
- package/package.json +4 -4
- package/src/styles/concierge.css +803 -28
- package/src/styles/tokens.css +67 -0
- package/dist/chunks/chat-DfajYOmN.js +0 -240
- package/dist/chunks/host-widget-C9EyGeiN.js +0 -9745
- package/dist/concierge-launcher.d.ts +0 -53
- package/dist/concierge-launcher.d.ts.map +0 -1
- package/dist/concierge-shell.d.ts +0 -256
- package/dist/concierge-shell.d.ts.map +0 -1
- package/dist/position.d.ts +0 -65
- package/dist/position.d.ts.map +0 -1
- package/dist/transcript-geometry.d.ts +0 -220
- package/dist/transcript-geometry.d.ts.map +0 -1
package/dist/messages.d.ts
CHANGED
|
@@ -45,6 +45,75 @@ export interface WidgetMessages {
|
|
|
45
45
|
readonly send: string;
|
|
46
46
|
readonly move: string;
|
|
47
47
|
readonly call_end: string;
|
|
48
|
+
/**
|
|
49
|
+
* DOCK_SPEC §3.2 — the dock pill's default label, when the tenant published
|
|
50
|
+
* no `copy[locale].minimisedLabel`. `dock_pill_hold` is the touch-with-voice
|
|
51
|
+
* default ("Hold to ask" names the actual gesture, §5.2); `dock_pill_ask`
|
|
52
|
+
* carries `{name}` and is the fallback everywhere the microphone is not
|
|
53
|
+
* available — a desktop pointer, `modalities.voice: false`, or an embedded
|
|
54
|
+
* webview (§8.4). A label promising a microphone that is not on screen is
|
|
55
|
+
* worse than no label at all.
|
|
56
|
+
*
|
|
57
|
+
* OPTIONAL, like every key added after 0.2.0 — see `handoff_event` below
|
|
58
|
+
* for the compatibility contract that makes that mandatory rather than
|
|
59
|
+
* stylistic.
|
|
60
|
+
*/
|
|
61
|
+
readonly dock_pill_hold?: string;
|
|
62
|
+
readonly dock_pill_ask?: string;
|
|
63
|
+
/**
|
|
64
|
+
* DOCK_SPEC §5.1 and §3.2 — every **spec** string the dock's caption, its
|
|
65
|
+
* controls and its sheet header render. "Spec" means ours, localised by us,
|
|
66
|
+
* as distinct from the **tenant** strings (`greeting`, `offlineMessage`,
|
|
67
|
+
* `minimisedLabel`) that come from `copy[locale]` and are authored per
|
|
68
|
+
* tenant.
|
|
69
|
+
*
|
|
70
|
+
* All OPTIONAL, like every key added after 0.2.0 — see `handoff_event`
|
|
71
|
+
* below for the published-interface compatibility contract that makes that
|
|
72
|
+
* mandatory rather than stylistic. A host with a complete catalogue of its
|
|
73
|
+
* own keeps compiling, and a missing key resolves against
|
|
74
|
+
* `defaultWidgetMessages` at the point of use, so an older catalogue
|
|
75
|
+
* renders shipped English rather than an empty row.
|
|
76
|
+
*
|
|
77
|
+
* | Key | State (§5.1) |
|
|
78
|
+
* | ------------------------ | --------------------------------------------------------------- |
|
|
79
|
+
* | `dock_connecting` | `connecting` — the only state allowed to block |
|
|
80
|
+
* | `dock_use_text` | `connecting`'s keyboard control: the text escape it must carry |
|
|
81
|
+
* | `dock_listening` | `listening`, until the recognizer produces words |
|
|
82
|
+
* | `dock_thinking` | `thinking`, only when no `preamble` arrived within `raceMs` |
|
|
83
|
+
* | `dock_interrupt` | `speaking` — labelled the first two times per visitor, icon after |
|
|
84
|
+
* | `dock_ducked` | `ducked` — a real pause, resumed by speech or a tap, never a timer |
|
|
85
|
+
* | `dock_still_here` | `reconnecting` — the most-seen state on a navigating storefront |
|
|
86
|
+
* | `dock_still_here_resume` | `reconnecting` after a lock/app-switch that dropped the room |
|
|
87
|
+
* | `dock_muted` | `muted` — a privacy control, not a convenience |
|
|
88
|
+
* | `dock_mic_blocked` | `mic_blocked` — degrades to text, never re-prompts |
|
|
89
|
+
* | `dock_fix_browser` | `mic_blocked`'s second control, offered once |
|
|
90
|
+
* | `dock_cards` | `cards` — carries `{count}` |
|
|
91
|
+
* | `dock_voice_failed` | a voice CONNECT that failed — the one line a shopper can act on |
|
|
92
|
+
* | `dock_show_transcript` | §3.4 — the sheet's header, voice sessions only |
|
|
93
|
+
* | `dock_earbuds` | §8.7 — offered once per session on a headset connect |
|
|
94
|
+
*/
|
|
95
|
+
readonly dock_connecting?: string;
|
|
96
|
+
readonly dock_use_text?: string;
|
|
97
|
+
readonly dock_listening?: string;
|
|
98
|
+
readonly dock_thinking?: string;
|
|
99
|
+
readonly dock_interrupt?: string;
|
|
100
|
+
readonly dock_ducked?: string;
|
|
101
|
+
readonly dock_still_here?: string;
|
|
102
|
+
readonly dock_still_here_resume?: string;
|
|
103
|
+
readonly dock_muted?: string;
|
|
104
|
+
readonly dock_mic_blocked?: string;
|
|
105
|
+
readonly dock_fix_browser?: string;
|
|
106
|
+
readonly dock_cards?: string;
|
|
107
|
+
/**
|
|
108
|
+
* §5.1 — shown INSTEAD of the transport error when the call could not be
|
|
109
|
+
* established at all ("could not establish signal connection: Failed to
|
|
110
|
+
* fetch" is what a blocked LiveKit host produces). The raw text still
|
|
111
|
+
* reaches `onError` and the console; the shopper gets the one sentence they
|
|
112
|
+
* can act on, next to the keyboard control that acts on it.
|
|
113
|
+
*/
|
|
114
|
+
readonly dock_voice_failed?: string;
|
|
115
|
+
readonly dock_show_transcript?: string;
|
|
116
|
+
readonly dock_earbuds?: string;
|
|
48
117
|
/**
|
|
49
118
|
* The handoff MARKER — the quiet inline divider in the transcript at the
|
|
50
119
|
* point the conversation was handed to a person. Past tense on purpose: it
|
|
@@ -101,6 +170,23 @@ export interface WidgetMessages {
|
|
|
101
170
|
readonly cart_summary_total: string;
|
|
102
171
|
readonly checkout_now: string;
|
|
103
172
|
readonly checkout_failed: string;
|
|
173
|
+
/**
|
|
174
|
+
* Shown on the host status line when the concierge asked this widget to add
|
|
175
|
+
* something (the `add_to_cart` tool) and the widget could NOT do it — no
|
|
176
|
+
* `addToCart` on the bridge, no id in the bridge's own space, or an add the
|
|
177
|
+
* storefront rejected.
|
|
178
|
+
*
|
|
179
|
+
* It exists because the concierge has, by that point, already said the item
|
|
180
|
+
* is going in the basket: it called a tool that succeeded server-side, and
|
|
181
|
+
* only the browser knows the add never landed. Saying nothing here is the
|
|
182
|
+
* one outcome this whole path must avoid — the shopper finds out at
|
|
183
|
+
* checkout instead. It names the product page rather than a retry, because
|
|
184
|
+
* the reasons are all structural: pressing again would fail the same way.
|
|
185
|
+
*
|
|
186
|
+
* Optional, like every key added to this interface after 0.2.0 — see
|
|
187
|
+
* `handoff_event` above for the published-interface compatibility contract.
|
|
188
|
+
*/
|
|
189
|
+
readonly cart_add_failed?: string;
|
|
104
190
|
/**
|
|
105
191
|
* The one-word voice-state pill under the orb, shown only while a call is
|
|
106
192
|
* active — see `ConciergeShellVoice.labels`'s matching four keys and the
|
package/dist/messages.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE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cG;IACH,QAAQ,CAAC,2BAA2B,CAAC,EAAE,MAAM,CAAC;CAC/C;AAED;;;;;GAKG;AACH;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,cAAc,CA6D1D,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAM9F;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAOzF;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC,CAGhG"}
|
package/dist/next/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { p as detectPage, t as ConciergeWidget } from "../chunks/host-widget-C0XT9lHX.js";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
3
3
|
import { usePathname, useRouter } from "next/navigation";
|
|
4
4
|
//#region src/next/use-next-bridge.ts
|
package/dist/session-log.d.ts
CHANGED
|
@@ -28,6 +28,13 @@ export declare const SESSION_EVENTS: readonly ['token_requested', 'token_receive
|
|
|
28
28
|
'session_config',
|
|
29
29
|
/** The caller typed a turn instead of speaking it. */
|
|
30
30
|
'text_sent',
|
|
31
|
+
/**
|
|
32
|
+
* The BROWSER told the worker something about the turn in flight —
|
|
33
|
+
* DOCK_SPEC §5.1/§5.2's control channel: an end-of-utterance hint on a
|
|
34
|
+
* hold-to-talk release, or a client-initiated interrupt carrying its
|
|
35
|
+
* reason. The detail is the frame's `type`, or the interrupt's reason.
|
|
36
|
+
*/
|
|
37
|
+
'control_sent',
|
|
31
38
|
/** A speech vendor refused — the call is up but a leg of it is silent. */
|
|
32
39
|
'vendor_error',
|
|
33
40
|
/** A tool rendered something on screen — product cards, a checkout control. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-log.d.ts","sourceRoot":"","sources":["../src/session-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,yDAAyD;AACzD,eAAO,MAAM,cAAc,YACzB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,WAAW,EACX,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,YAAY;AACZ,0DAA0D;AAC1D,cAAc;AACd,2EAA2E;AAC3E,gBAAgB;AAChB,sDAAsD;AACtD,WAAW;AACX,0EAA0E;AAC1E,cAAc;AACd,+EAA+E;AAC/E,cAAc;AACd,iFAAiF;AACjF,sBAAsB,EACtB,cAAc,EACd,SAAS,EACT,OAAO,EAQP,eAAe,EAKf,oBAAoB,CACZ,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,sDAAsD;IACtD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,6CAA6C;IAC7C,QAAQ,CAAC,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f;AAED,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAG3C"}
|
package/dist/session-panel.d.ts
CHANGED
|
@@ -2,8 +2,18 @@ import type { TranscriptPayload, TurnLatencyPayload } from '@saar-ai/widget-prot
|
|
|
2
2
|
import { type SessionLogEntry } from './session-log.js';
|
|
3
3
|
export interface SessionPanelProps {
|
|
4
4
|
readonly events: readonly SessionLogEntry[];
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* 0..1 RMS of the agent's incoming audio, as a LIVE REF (§7.1 rule 5).
|
|
7
|
+
*
|
|
8
|
+
* `useVoiceSession` hands this straight over. It changes on every animation
|
|
9
|
+
* frame, so the meter below reads it inside its own `requestAnimationFrame`
|
|
10
|
+
* and writes the transform to the DOM; a number prop would re-render this
|
|
11
|
+
* panel — and everything else holding the value — sixty times a second.
|
|
12
|
+
* A static caller (a story, a screenshot) passes `{ current: 0.42 }`.
|
|
13
|
+
*/
|
|
14
|
+
readonly agentLevelRef: {
|
|
15
|
+
readonly current: number;
|
|
16
|
+
};
|
|
7
17
|
readonly phase: string;
|
|
8
18
|
readonly micOpen: boolean;
|
|
9
19
|
readonly error: string | null;
|
|
@@ -11,5 +21,5 @@ export interface SessionPanelProps {
|
|
|
11
21
|
readonly turns: readonly TurnLatencyPayload[];
|
|
12
22
|
readonly transcript: readonly TranscriptPayload[];
|
|
13
23
|
}
|
|
14
|
-
export declare function SessionPanel({ events,
|
|
24
|
+
export declare function SessionPanel({ events, agentLevelRef, phase, micOpen, error, turns, transcript, }: SessionPanelProps): import("react").JSX.Element;
|
|
15
25
|
//# sourceMappingURL=session-panel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-panel.d.ts","sourceRoot":"","sources":["../src/session-panel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session-panel.d.ts","sourceRoot":"","sources":["../src/session-panel.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAEhG,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAwBlF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;IAC5C;;;;;;;;OAQG;IACH,QAAQ,CAAC,aAAa,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAC9C,QAAQ,CAAC,UAAU,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACnD;AAWD,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,aAAa,EACb,KAAK,EACL,OAAO,EACP,KAAK,EACL,KAAK,EACL,UAAU,GACX,EAAE,iBAAiB,+BAsKnB"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* COLOUR MATHS for the dock's derived theme (docs/DOCK_SPEC.md §9.2).
|
|
3
|
+
*
|
|
4
|
+
* Pure functions, zero dependencies, no DOM. That is a hard requirement, not
|
|
5
|
+
* a preference: `deriveTheme` runs in three places with three different
|
|
6
|
+
* budgets — the console's live preview (Node/browser, React), the CDN `core`
|
|
7
|
+
* stage (inlined into a ~20 KB min+gz artefact that must paint the resting
|
|
8
|
+
* row before any framework loads), and the React dock (adopted stylesheet).
|
|
9
|
+
* A colour library, a `color-mix()` call, or anything that needs a live
|
|
10
|
+
* CSSOM would each break at least one of those three.
|
|
11
|
+
*
|
|
12
|
+
* WHY WE COMPUTE INSTEAD OF LETTING CSS DO IT. `color-mix(in oklch, ...)` and
|
|
13
|
+
* relative colour syntax express every derivation here in one line, and both
|
|
14
|
+
* are unusable for us: the `core` stage writes tokens as an INLINE `style`
|
|
15
|
+
* attribute on the shadow host before any stylesheet exists, so the values it
|
|
16
|
+
* writes have to already be plain colours; and the publish-time validator
|
|
17
|
+
* (§9.3) has to ASSERT the contrast of the derived text, which means the
|
|
18
|
+
* numbers must exist in JavaScript, not only in a browser's style resolver.
|
|
19
|
+
*
|
|
20
|
+
* Colour space is Björn Ottosson's OKLab/OKLCH throughout, because hue
|
|
21
|
+
* rotation (`--wgt-accent`) and mixing (`--wgt-surface-2`) both have to be
|
|
22
|
+
* perceptually even — an HSL rotation off a brand teal lands somewhere a
|
|
23
|
+
* designer would reject, and a naive sRGB channel mix darkens far too fast.
|
|
24
|
+
* Contrast, by contrast (sorry), is WCAG 2.x relative luminance, because that
|
|
25
|
+
* — not any perceptual metric — is what §9.3 promises and what an auditor
|
|
26
|
+
* measures.
|
|
27
|
+
*/
|
|
28
|
+
/** sRGB in 0..1 per channel, plus alpha. The parsed form of a hex string. */
|
|
29
|
+
export interface Rgb {
|
|
30
|
+
r: number;
|
|
31
|
+
g: number;
|
|
32
|
+
b: number;
|
|
33
|
+
a: number;
|
|
34
|
+
}
|
|
35
|
+
/** OKLab. `L` 0..1, `a`/`b` roughly -0.4..0.4. */
|
|
36
|
+
export interface Oklab {
|
|
37
|
+
L: number;
|
|
38
|
+
a: number;
|
|
39
|
+
b: number;
|
|
40
|
+
}
|
|
41
|
+
/** OKLCH. `L` 0..1, `C` 0..~0.37 in sRGB, `h` degrees 0..360. */
|
|
42
|
+
export interface Oklch {
|
|
43
|
+
L: number;
|
|
44
|
+
C: number;
|
|
45
|
+
h: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Parse `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa` (leading `#` optional) into
|
|
49
|
+
* 0..1 channels.
|
|
50
|
+
*
|
|
51
|
+
* @throws {TypeError} on anything else — a tenant's published config is
|
|
52
|
+
* validated at publish (§9.3), so an unparsable hex reaching here is a bug in
|
|
53
|
+
* the caller, and returning a fallback colour would hide it behind a widget
|
|
54
|
+
* that merely looks wrong on someone else's storefront.
|
|
55
|
+
*/
|
|
56
|
+
export declare function parseHex(hex: string): Rgb;
|
|
57
|
+
/** `#rrggbb`, lowercase. Alpha is dropped — every `--wgt-*` colour token that
|
|
58
|
+
* needs transparency goes through {@link withAlpha} instead. */
|
|
59
|
+
export declare function formatHex(rgb: Rgb | {
|
|
60
|
+
r: number;
|
|
61
|
+
g: number;
|
|
62
|
+
b: number;
|
|
63
|
+
}): string;
|
|
64
|
+
/** sRGB transfer function, inverse (encoded → linear-light). */
|
|
65
|
+
export declare function srgbToLinear(c: number): number;
|
|
66
|
+
/** sRGB transfer function (linear-light → encoded). */
|
|
67
|
+
export declare function linearToSrgb(c: number): number;
|
|
68
|
+
/** Linear-light sRGB → OKLab (Ottosson's M1/M2 matrices). */
|
|
69
|
+
export declare function linearRgbToOklab(r: number, g: number, b: number): Oklab;
|
|
70
|
+
/** OKLab → linear-light sRGB. May land OUTSIDE 0..1 (out of gamut). */
|
|
71
|
+
export declare function oklabToLinearRgb(lab: Oklab): {
|
|
72
|
+
r: number;
|
|
73
|
+
g: number;
|
|
74
|
+
b: number;
|
|
75
|
+
};
|
|
76
|
+
export declare function oklabToOklch(lab: Oklab): Oklch;
|
|
77
|
+
export declare function oklchToOklab(lch: Oklch): Oklab;
|
|
78
|
+
/** Hex → OKLab. */
|
|
79
|
+
export declare function hexToOklab(hex: string): Oklab;
|
|
80
|
+
/** Hex → OKLCH. */
|
|
81
|
+
export declare function hexToOklch(hex: string): Oklch;
|
|
82
|
+
/**
|
|
83
|
+
* OKLab → `#rrggbb`, gamut-mapped by REDUCING CHROMA at constant L and h.
|
|
84
|
+
*
|
|
85
|
+
* The naive alternative — clamp each channel into 0..1 — is what makes a hue
|
|
86
|
+
* rotation lie: clipping a channel moves the colour sideways in hue, so
|
|
87
|
+
* `--wgt-accent` derived as "primary + 30°" comes back as anything from +18°
|
|
88
|
+
* to +45° depending on which channel blew out. `derive.test.ts` asserts the
|
|
89
|
+
* accent's hue to within 1°, and this binary search is what makes that
|
|
90
|
+
* assertion satisfiable at all. 24 halvings resolves chroma far finer than
|
|
91
|
+
* the 8-bit output can represent, so the loop is a fixed, tiny cost.
|
|
92
|
+
*/
|
|
93
|
+
export declare function oklabToHex(lab: Oklab): string;
|
|
94
|
+
/** OKLCH → `#rrggbb`, gamut-mapped as {@link oklabToHex} describes. */
|
|
95
|
+
export declare function oklchToHex(lch: Oklch): string;
|
|
96
|
+
/** WCAG 2.x relative luminance (0 = black, 1 = white). */
|
|
97
|
+
export declare function relativeLuminance(hex: string): number;
|
|
98
|
+
/** WCAG 2.x contrast ratio, 1..21. Symmetric in its arguments. */
|
|
99
|
+
export declare function contrastRatio(a: string, b: string): number;
|
|
100
|
+
/**
|
|
101
|
+
* `rgb(r g b / a)` — the CSS Color 4 space-separated form.
|
|
102
|
+
*
|
|
103
|
+
* Not `#rrggbbaa`: the alpha tokens (`--wgt-text-muted`, `--wgt-border`,
|
|
104
|
+
* `--wgt-ring`) are read back by the console preview and by tests, and a
|
|
105
|
+
* decimal alpha stays legible there instead of becoming a byte nobody can
|
|
106
|
+
* eyeball. Both forms have identical browser support inside our floor.
|
|
107
|
+
*/
|
|
108
|
+
export declare function withAlpha(hex: string, alpha: number): string;
|
|
109
|
+
/** Rotate a colour's OKLCH hue by `deg`, holding L and C (chroma may be
|
|
110
|
+
* gamut-reduced by the conversion back — hue never is). */
|
|
111
|
+
export declare function rotateHue(hex: string, deg: number): string;
|
|
112
|
+
/** Linearly interpolate `hex` toward `towardHex` by `t` (0..1) in OKLab. */
|
|
113
|
+
export declare function mixToward(hex: string, towardHex: string, t: number): string;
|
|
114
|
+
//# sourceMappingURL=color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../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GAAG,EAAE,KAAK,GAAG,KAAK,CAI9C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,KAAK,GAAG,KAAK,CAG9C;AAED,mBAAmB;AACnB,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAG7C;AAED,mBAAmB;AACnB,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAE7C;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,KAAK,GAAG,MAAM,CAuB7C;AAED,uEAAuE;AACvE,wBAAgB,UAAU,CAAC,GAAG,EAAE,KAAK,GAAG,MAAM,CAE7C;AAED,0DAA0D;AAC1D,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED,kEAAkE;AAClE,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAM1D;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAM5D;AAED;2DAC2D;AAC3D,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAW3E"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export type WidgetTone = 'light' | 'dark' | 'auto';
|
|
2
|
+
export type WidgetFont = 'inherit' | 'system';
|
|
3
|
+
export type WidgetRadius = 'square' | 'soft' | 'round' | 'pill';
|
|
4
|
+
export type WidgetCaps = 'none' | 'buttons';
|
|
5
|
+
/** §9.1's `color` group. */
|
|
6
|
+
export interface WidgetColorConfig {
|
|
7
|
+
primary: string;
|
|
8
|
+
accent?: string;
|
|
9
|
+
surface?: string;
|
|
10
|
+
tone: WidgetTone;
|
|
11
|
+
}
|
|
12
|
+
/** §9.1's `type` group. */
|
|
13
|
+
export interface WidgetTypeConfig {
|
|
14
|
+
font: WidgetFont;
|
|
15
|
+
radius: WidgetRadius;
|
|
16
|
+
caps: WidgetCaps;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Every token §9.2 defines, in the order they are emitted. Declaration order
|
|
20
|
+
* is part of the contract: `themeToCss`'s output is snapshotted, and a reader
|
|
21
|
+
* comparing a rendered block against the spec table should not have to sort.
|
|
22
|
+
*/
|
|
23
|
+
export declare const WIDGET_THEME_TOKENS: readonly ['--wgt-primary', '--wgt-on-primary', '--wgt-accent', '--wgt-surface', '--wgt-surface-2', '--wgt-text', '--wgt-text-muted', '--wgt-border', '--wgt-ring', '--wgt-radius', '--wgt-sheet-radius', '--wgt-card-radius', '--wgt-font', '--wgt-caps'];
|
|
24
|
+
export type WidgetThemeVar = (typeof WIDGET_THEME_TOKENS)[number];
|
|
25
|
+
export type WidgetThemeVars = Record<WidgetThemeVar, string>;
|
|
26
|
+
/**
|
|
27
|
+
* `light` is the UNCONDITIONAL block — the one written straight onto the
|
|
28
|
+
* selector — not "the light appearance". For `tone: 'dark'` it carries the
|
|
29
|
+
* dark derivation and `dark` is absent; `dark` exists only for `tone: 'auto'`,
|
|
30
|
+
* where it is the block that goes behind `@media (prefers-color-scheme:
|
|
31
|
+
* dark)`. Naming the fields after their CSS position rather than their
|
|
32
|
+
* colours is what keeps {@link themeToCss} trivial.
|
|
33
|
+
*/
|
|
34
|
+
export interface DerivedWidgetTheme {
|
|
35
|
+
light: WidgetThemeVars;
|
|
36
|
+
dark?: WidgetThemeVars;
|
|
37
|
+
}
|
|
38
|
+
/** §9.1 `type.font: 'system'`. Deliberately a plain stack — no webfont, no
|
|
39
|
+
* network request on a merchant's page. */
|
|
40
|
+
export declare const SYSTEM_FONT_STACK = "system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif";
|
|
41
|
+
/**
|
|
42
|
+
* §3.3 — the ceilings the SHEET and the cards inside it put on the tenant's
|
|
43
|
+
* radius.
|
|
44
|
+
*
|
|
45
|
+
* `type.radius: 'pill'` is 9999px, and that is what the row and the pill are
|
|
46
|
+
* FOR: a fully rounded 48 px bar. The same value on the sheet's top corners
|
|
47
|
+
* is not a rounded sheet, it is an ellipse the width of the viewport, and it
|
|
48
|
+
* turns the shelf's 64 px thumbnails into circles. The cap belongs to the
|
|
49
|
+
* SURFACE rather than to the tenant, so a pill tenant still gets its pill row
|
|
50
|
+
* and its pill controls.
|
|
51
|
+
*
|
|
52
|
+
* Resolved to a number here rather than emitted as a CSS `min()`: the `core`
|
|
53
|
+
* stage writes these tokens as an inline `style` attribute before any
|
|
54
|
+
* stylesheet exists ({@link themeToInlineStyle}), and §9.3's publish-time
|
|
55
|
+
* validator reads the values in JavaScript — the same two reasons no other
|
|
56
|
+
* token here is a CSS function.
|
|
57
|
+
*/
|
|
58
|
+
export declare const SHEET_RADIUS_MAX_PX = 20;
|
|
59
|
+
export declare const CARD_RADIUS_MAX_PX = 12;
|
|
60
|
+
/**
|
|
61
|
+
* Derive every `--wgt-*` token from the published `color` + `type` groups.
|
|
62
|
+
*
|
|
63
|
+
* Deterministic and side-effect free: the same inputs always produce the same
|
|
64
|
+
* strings, which is what lets the console preview, the `core` stage and the
|
|
65
|
+
* React dock render the same theme without sharing state.
|
|
66
|
+
*
|
|
67
|
+
* @throws {TypeError} on an unparsable hex or an unknown enum value. A
|
|
68
|
+
* published config is validated at §9.3, so either is a caller bug — and a
|
|
69
|
+
* fallback colour here would ship a wrong-looking widget on a merchant's site
|
|
70
|
+
* instead of failing where someone can see it.
|
|
71
|
+
*/
|
|
72
|
+
export declare function deriveTheme(color: WidgetColorConfig, type: WidgetTypeConfig): DerivedWidgetTheme;
|
|
73
|
+
/**
|
|
74
|
+
* The theme as a CSS text block: the unconditional rule, plus — for
|
|
75
|
+
* `tone: 'auto'` — a `prefers-color-scheme: dark` override on the same
|
|
76
|
+
* selector, exactly as §9.2 requires ("both defined on `:host`").
|
|
77
|
+
*
|
|
78
|
+
* `:host` is the default because the dock lives in a shadow root; pass a class
|
|
79
|
+
* or `:root` for the console preview, which renders in light DOM.
|
|
80
|
+
*/
|
|
81
|
+
export declare function themeToCss(theme: DerivedWidgetTheme, selector?: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* The theme as a `style` attribute value, for the `core` stage — which paints
|
|
84
|
+
* the resting row before any stylesheet, adopted or otherwise, exists.
|
|
85
|
+
*
|
|
86
|
+
* `tone: 'auto'`'s dark block has no inline equivalent (an attribute cannot
|
|
87
|
+
* carry a media query); `core` passes whichever block matches the page's
|
|
88
|
+
* current `prefers-color-scheme` and the adopted stylesheet takes over the
|
|
89
|
+
* responsiveness at the React handover.
|
|
90
|
+
*/
|
|
91
|
+
export declare function themeToInlineStyle(vars: WidgetThemeVars): string;
|
|
92
|
+
//# sourceMappingURL=derive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../../src/theme/derive.ts"],"names":[],"mappings":"AA0CA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AACnD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC9C,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAChE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;AAE5C,4BAA4B;AAC5B,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,2BAA2B;AAC3B,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,YAC9B,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,YAAY,CACJ,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAClE,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,eAAe,CAAC;IACvB,IAAI,CAAC,EAAE,eAAe,CAAC;CACxB;AAED;2CAC2C;AAC3C,eAAO,MAAM,iBAAiB,0FACuD,CAAC;AAUtF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,kBAAkB,KAAK,CAAC;AA4MrC;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,gBAAgB,GAAG,kBAAkB,CA2BhG;AAOD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,kBAAkB,EAAE,QAAQ,SAAU,GAAG,MAAM,CAMhF;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAEhE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@saar-ai/web-widget`'s theme derivation (docs/DOCK_SPEC.md §9.2).
|
|
3
|
+
*
|
|
4
|
+
* Two modules, both pure and dependency-free so the CDN `core` stage can
|
|
5
|
+
* inline them inside its budget: `color.ts` (sRGB/OKLab/OKLCH conversion and
|
|
6
|
+
* WCAG contrast) and `derive.ts` (the config → `--wgt-*` token derivation).
|
|
7
|
+
*/
|
|
8
|
+
export * from './color.js';
|
|
9
|
+
export * from './derive.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arrival-order stamping for the merged transcript `ConciergeWidget` renders.
|
|
3
|
+
*
|
|
4
|
+
* The typed session, the spoken transcript and the voice tool events are three
|
|
5
|
+
* lists with no shared clock (`use-chat-session` stamps nothing; the voice
|
|
6
|
+
* worker's `atMs` is ITS clock, optional on the wire, and absent from typed
|
|
7
|
+
* turns entirely). What the widget CAN observe is arrival: it re-renders every
|
|
8
|
+
* time any of the three lists changes, so "which render did this row first
|
|
9
|
+
* appear in" is a total order over everything on screen — exactly the order a
|
|
10
|
+
* shopper watched the conversation happen in.
|
|
11
|
+
*
|
|
12
|
+
* `TurnOrderClock` hands every row a monotonic stamp on first sight and
|
|
13
|
+
* remembers it for the rest of the widget's life, so the merged transcript can
|
|
14
|
+
* simply sort by stamp. The three sources mutate differently, so each gets its
|
|
15
|
+
* own concrete rules — no generic aligner whose predicates a reader must
|
|
16
|
+
* re-derive per source:
|
|
17
|
+
*
|
|
18
|
+
* - **Typed turns** (`stampTyped`) — keyed by `id`, with one wrinkle: an id
|
|
19
|
+
* is rewritten IN PLACE once per turn (`send` swaps the optimistic caller
|
|
20
|
+
* id for the server's; `onDone` does the same for the streamed agent
|
|
21
|
+
* bubble, and may REMOVE a poll-backfilled duplicate of the same server id
|
|
22
|
+
* in the same update). A rewritten row must keep its stamp or it would
|
|
23
|
+
* leapfrog a spoken line that arrived while it was streaming. The list can
|
|
24
|
+
* also SHRINK: a failed `send` rolls its two optimistic rows back, and a
|
|
25
|
+
* recovery re-boot replaces the whole list — neither may donate a dead
|
|
26
|
+
* row's stamp to an unrelated newcomer.
|
|
27
|
+
* - **Spoken lines** (`stampSpoken`) — no stable key at all: a provisional
|
|
28
|
+
* line is REVISED IN PLACE as a brand-new object (`coalesceTranscript`),
|
|
29
|
+
* the list is capped (`slice(-MAX_TRANSCRIPT_LINES)` shifts everything
|
|
30
|
+
* left), and `start()` resets it to `[]` for a new call.
|
|
31
|
+
* - **Voice tool events** (`stampEvent`) — append-only distinct objects, a
|
|
32
|
+
* `WeakMap` by identity.
|
|
33
|
+
*/
|
|
34
|
+
/** The fields of a typed turn the clock needs — a structural subset of `ChatTurn`. */
|
|
35
|
+
export interface TypedTurnLike {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly speaker: 'caller' | 'agent' | 'event';
|
|
38
|
+
}
|
|
39
|
+
/** The fields of a spoken transcript line the clock needs — a structural subset of `TranscriptPayload`. */
|
|
40
|
+
export interface SpokenLineLike {
|
|
41
|
+
readonly speaker: 'caller' | 'agent';
|
|
42
|
+
readonly final: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The widget's arrival clock. One instance per mounted widget (`useRef`), fed
|
|
46
|
+
* the CURRENT source lists on every render; every call is idempotent for
|
|
47
|
+
* unchanged input, so React StrictMode's double-invoked render (and any memo
|
|
48
|
+
* re-run) hands back identical stamps.
|
|
49
|
+
*/
|
|
50
|
+
export declare class TurnOrderClock {
|
|
51
|
+
private counter;
|
|
52
|
+
private typedPrev;
|
|
53
|
+
private typedStamps;
|
|
54
|
+
private spokenPrev;
|
|
55
|
+
private spokenStamps;
|
|
56
|
+
private readonly eventStamps;
|
|
57
|
+
private fresh;
|
|
58
|
+
/**
|
|
59
|
+
* Stamps for the typed session's turns, parallel to `turns`.
|
|
60
|
+
*
|
|
61
|
+
* Per row, in order of precedence:
|
|
62
|
+
*
|
|
63
|
+
* 1. **Positional rewrite** — the row at this INDEX last render had a
|
|
64
|
+
* different id that no longer exists anywhere in the list, and the same
|
|
65
|
+
* speaker: that is `send`/`onDone`'s in-place id swap, so the stamp
|
|
66
|
+
* carries over. Checked BEFORE the id lookup because of the one race
|
|
67
|
+
* where both would match: the poll can backfill the streaming turn's
|
|
68
|
+
* server row before `onDone` renames the streamed bubble to that same
|
|
69
|
+
* id and drops the duplicate — the id lookup alone would hand the
|
|
70
|
+
* bubble the DUPLICATE's later stamp and orphan every row between.
|
|
71
|
+
* 2. **Id match** — the row was here last render; same stamp.
|
|
72
|
+
* 3. **Fresh** — a genuinely new row, which sorts after everything already
|
|
73
|
+
* on screen. This is where a row lands when a failed `send`'s rollback
|
|
74
|
+
* and a new append batch into one render: the newcomer stands at a
|
|
75
|
+
* removed OPTIMISTIC row's index, but the speaker gate in rule 1 (and
|
|
76
|
+
* the dead id in rule 2) keep it from inheriting the dead row's past.
|
|
77
|
+
*/
|
|
78
|
+
stampTyped(turns: readonly TypedTurnLike[]): readonly number[];
|
|
79
|
+
/**
|
|
80
|
+
* Stamps for the voice transcript, parallel to `lines` — the FULL list as
|
|
81
|
+
* `useVoiceSession` publishes it, before any render-side filtering, so the
|
|
82
|
+
* caller can filter lines and stamps together.
|
|
83
|
+
*
|
|
84
|
+
* Rows are matched by object IDENTITY, scanning forward only — which is
|
|
85
|
+
* what lets the cap trim (the whole list shifted left one) keep every
|
|
86
|
+
* surviving stamp. An unmatched row standing where an unmatched PROVISIONAL
|
|
87
|
+
* line of the same speaker stood is `coalesceTranscript`'s in-place
|
|
88
|
+
* revision and inherits that line's stamp; anything else is new and stamps
|
|
89
|
+
* fresh, after everything already seen.
|
|
90
|
+
*
|
|
91
|
+
* Inheritance is disabled outright on a render where the list SHRANK:
|
|
92
|
+
* appends and revisions never shrink it and the cap trim keeps the length
|
|
93
|
+
* constant, so a shorter list means rows were dropped (`start()`'s reset to
|
|
94
|
+
* `[]` for a new call, or any future producer change) — and a dropped
|
|
95
|
+
* line's stamp must never be donated to a newcomer that merely stands where
|
|
96
|
+
* it stood. Surviving identical rows still keep their stamps; everything
|
|
97
|
+
* else restamps fresh, i.e. the new call's lines sort after everything
|
|
98
|
+
* already said. (`start()`'s clear commits as its own render before any
|
|
99
|
+
* frame from the new room can arrive, so in practice the reset is observed
|
|
100
|
+
* as `[]` and this guard is belt and braces.)
|
|
101
|
+
*/
|
|
102
|
+
stampSpoken(lines: readonly SpokenLineLike[]): readonly number[];
|
|
103
|
+
/** Stamp for one voice tool event — append-only distinct objects, so plain first-sight identity. */
|
|
104
|
+
stampEvent(event: object): number;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=turn-order.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-order.d.ts","sourceRoot":"","sources":["../src/turn-order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,sFAAsF;AACtF,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;CAChD;AAED,2GAA2G;AAC3G,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;;;;GAKG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,WAAW,CAAyB;IAC5C,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,YAAY,CAAyB;IAC7C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiC;IAE7D,OAAO,CAAC,KAAK;IAKb;;;;;;;;;;;;;;;;;;;OAmBG;IACH,UAAU,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,SAAS,MAAM,EAAE,CAqB7D;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,WAAW,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,GAAG,SAAS,MAAM,EAAE,CAkC/D;IAED,oGAAoG;IACpG,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMhC;CACF"}
|