sgiant-ai-widget 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +155 -0
- package/dist/ai-invalidation.d.ts +29 -0
- package/dist/ai-invalidation.d.ts.map +1 -0
- package/dist/ai-invalidation.js +121 -0
- package/dist/ai-invalidation.js.map +1 -0
- package/dist/contrast.d.ts +87 -0
- package/dist/contrast.d.ts.map +1 -0
- package/dist/contrast.js +151 -0
- package/dist/contrast.js.map +1 -0
- package/dist/directive.d.ts +37 -0
- package/dist/directive.d.ts.map +1 -0
- package/dist/directive.js +87 -0
- package/dist/directive.js.map +1 -0
- package/dist/dom.d.ts +83 -0
- package/dist/dom.d.ts.map +1 -0
- package/dist/dom.js +146 -0
- package/dist/dom.js.map +1 -0
- package/dist/host-actions.d.ts +192 -0
- package/dist/host-actions.d.ts.map +1 -0
- package/dist/host-actions.js +443 -0
- package/dist/host-actions.js.map +1 -0
- package/dist/icons.d.ts +21 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +84 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +600 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4833 -0
- package/dist/index.js.map +1 -0
- package/dist/labels.d.ts +187 -0
- package/dist/labels.d.ts.map +1 -0
- package/dist/labels.js +232 -0
- package/dist/labels.js.map +1 -0
- package/dist/limits.d.ts +43 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/limits.js +48 -0
- package/dist/limits.js.map +1 -0
- package/dist/markdown.d.ts +23 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +0 -0
- package/dist/markdown.js.map +1 -0
- package/dist/message-chrome.d.ts +45 -0
- package/dist/message-chrome.d.ts.map +1 -0
- package/dist/message-chrome.js +101 -0
- package/dist/message-chrome.js.map +1 -0
- package/dist/pane-follow.d.ts +67 -0
- package/dist/pane-follow.d.ts.map +1 -0
- package/dist/pane-follow.js +61 -0
- package/dist/pane-follow.js.map +1 -0
- package/dist/prefix.d.ts +9 -0
- package/dist/prefix.d.ts.map +1 -0
- package/dist/prefix.js +9 -0
- package/dist/prefix.js.map +1 -0
- package/dist/proposal-summary.d.ts +19 -0
- package/dist/proposal-summary.d.ts.map +1 -0
- package/dist/proposal-summary.js +73 -0
- package/dist/proposal-summary.js.map +1 -0
- package/dist/replay.d.ts +125 -0
- package/dist/replay.d.ts.map +1 -0
- package/dist/replay.js +172 -0
- package/dist/replay.js.map +1 -0
- package/dist/safe-url.d.ts +47 -0
- package/dist/safe-url.d.ts.map +1 -0
- package/dist/safe-url.js +80 -0
- package/dist/safe-url.js.map +1 -0
- package/dist/sgiant-ai-widget.global.js +778 -0
- package/dist/sgiant-ai-widget.global.js.map +7 -0
- package/dist/specs.d.ts +173 -0
- package/dist/specs.d.ts.map +1 -0
- package/dist/specs.js +231 -0
- package/dist/specs.js.map +1 -0
- package/dist/storage.d.ts +77 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +124 -0
- package/dist/storage.js.map +1 -0
- package/dist/styles.d.ts +29 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +876 -0
- package/dist/styles.js.map +1 -0
- package/dist/ui-control.d.ts +8 -0
- package/dist/ui-control.d.ts.map +1 -0
- package/dist/ui-control.js +8 -0
- package/dist/ui-control.js.map +1 -0
- package/dist/ui-render.d.ts +75 -0
- package/dist/ui-render.d.ts.map +1 -0
- package/dist/ui-render.js +617 -0
- package/dist/ui-render.js.map +1 -0
- package/dist/ui-spec.d.ts +143 -0
- package/dist/ui-spec.d.ts.map +1 -0
- package/dist/ui-spec.js +288 -0
- package/dist/ui-spec.js.map +1 -0
- package/package.json +61 -0
package/dist/labels.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every string the widget's own chrome can show, and the host adapter that
|
|
3
|
+
* translates them.
|
|
4
|
+
*
|
|
5
|
+
* Its own module (#320) because it is read by three hosts and a parity test,
|
|
6
|
+
* and none of them wants the 5800-line widget closure to get at a string table.
|
|
7
|
+
* `WidgetLabels` being derived from this object is what makes a missing
|
|
8
|
+
* translation a TYPE error in each host rather than an English word appearing
|
|
9
|
+
* in a Turkish UI.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* SINGLE SOURCE for every user-facing string baked into the vanilla-DOM widget,
|
|
13
|
+
* with its English default. The widget can't call i18next, so the host passes a
|
|
14
|
+
* translated `labels` bag (built by `resolveWidgetLabels`); the widget falls back
|
|
15
|
+
* to these English defaults for any missing key. A `{token}` in a value is filled
|
|
16
|
+
* at runtime by the widget (single-brace so a host's i18next leaves it intact).
|
|
17
|
+
*/
|
|
18
|
+
export const WIDGET_LABELS = {
|
|
19
|
+
// Question cards — the assistant asking the human to decide.
|
|
20
|
+
questionConfirm: "Send",
|
|
21
|
+
questionPlaceholder: "Type your answer…",
|
|
22
|
+
questionSendFailed: "Couldn't send your answer — wait for the current reply to finish, then try again.",
|
|
23
|
+
// Header / bubble
|
|
24
|
+
openBubble: "Open {name}",
|
|
25
|
+
openBubbleUnread: "Open {name} — {count} unread",
|
|
26
|
+
panelAria: "{name} chat",
|
|
27
|
+
newChat: "New chat",
|
|
28
|
+
pastConversations: "Past conversations",
|
|
29
|
+
/** History-row spinner tooltip: this conversation has a reply in flight. */
|
|
30
|
+
threadAnswering: "Answering…",
|
|
31
|
+
/** Shown when the live stream drops mid-reply: the server finishes the turn
|
|
32
|
+
* and the widget polls the thread until the reply lands. */
|
|
33
|
+
streamLostRecovering: "Connection lost — still working on the reply; it will appear here when ready.",
|
|
34
|
+
history: "History",
|
|
35
|
+
moreOptions: "More options",
|
|
36
|
+
more: "More",
|
|
37
|
+
expandChat: "Expand chat",
|
|
38
|
+
expand: "Expand",
|
|
39
|
+
restore: "Restore",
|
|
40
|
+
restoreChat: "Restore chat size",
|
|
41
|
+
closeChat: "Close chat",
|
|
42
|
+
conversation: "Conversation",
|
|
43
|
+
// "More" overflow menu
|
|
44
|
+
on: "On",
|
|
45
|
+
off: "Off",
|
|
46
|
+
downloadChat: "Download chat (.txt)",
|
|
47
|
+
flagConversation: "Flag this conversation",
|
|
48
|
+
flagConversationHint: "Flag this conversation for review",
|
|
49
|
+
flagSendFirst: "Send a message first — then you can flag this chat.",
|
|
50
|
+
flagPrompt: "Flag this conversation — why? (reason is logged for review)",
|
|
51
|
+
flagged: "🚩 Conversation flagged for review ✓",
|
|
52
|
+
flagFailed: "Couldn't flag: {msg}",
|
|
53
|
+
flagFailedGeneric: "please try again",
|
|
54
|
+
notificationSound: "Notification sound",
|
|
55
|
+
soundOnHint: "Chime when a reply arrives — click to mute",
|
|
56
|
+
soundOffHint: "Muted — click to enable the reply chime",
|
|
57
|
+
autoNavigate: "Auto-navigate",
|
|
58
|
+
autoNavOnHint: "Copilot opens pages for you — click to turn off",
|
|
59
|
+
autoNavOffHint: "Copilot asks before opening pages — click to turn on",
|
|
60
|
+
// Status bar (Copilot role + credits)
|
|
61
|
+
roleTalk: "Talk",
|
|
62
|
+
roleAnalytics: "Analytics",
|
|
63
|
+
creditsSuffix: " credits",
|
|
64
|
+
// Composer
|
|
65
|
+
askAnything: "Ask {name} anything…",
|
|
66
|
+
messageAria: "Message {name}",
|
|
67
|
+
send: "Send",
|
|
68
|
+
removeAttachment: "Remove {file}",
|
|
69
|
+
attachFile: "Attach a file",
|
|
70
|
+
attachFileHint: "Attach images, PDFs or documents",
|
|
71
|
+
// Live background-job card — a job the chat started and now watches. The
|
|
72
|
+
// titles are per known TYPE, with a neutral fallback for a type this build
|
|
73
|
+
// has never heard of (an AI-defined job type must still render).
|
|
74
|
+
jobTitleCoder: "Working on a code task",
|
|
75
|
+
jobTitleReport: "Generating the report",
|
|
76
|
+
jobTitleFallback: "Background job",
|
|
77
|
+
jobQueued: "Queued",
|
|
78
|
+
jobRunning: "Running",
|
|
79
|
+
jobDone: "Finished",
|
|
80
|
+
jobFailed: "Failed",
|
|
81
|
+
jobCancelled: "Cancelled",
|
|
82
|
+
jobCancel: "Cancel",
|
|
83
|
+
jobCancelling: "Cancelling…",
|
|
84
|
+
jobProgress: "{done} of {total}",
|
|
85
|
+
/** Used while the total is still unknown — a report learns it once planned. */
|
|
86
|
+
jobProgressOpen: "{done} so far",
|
|
87
|
+
jobOpenResult: "Open the result",
|
|
88
|
+
/** Toggle under the flow tail that reveals the job's full activity feed. */
|
|
89
|
+
jobFlowAll: "Show all {count} steps",
|
|
90
|
+
/** Shown INSTEAD of the step feed when the app pane is already showing this
|
|
91
|
+
* run — see the collapse in renderJobCard. */
|
|
92
|
+
jobWatchingInPane: "Following along in the panel →",
|
|
93
|
+
/** Advanced view — the pane is showing a computed widget, not a route. */
|
|
94
|
+
paneBackToPage: "Back to the page",
|
|
95
|
+
paneShowingWidget: "Result",
|
|
96
|
+
jobUnreachable: "Still running in the background — check back shortly",
|
|
97
|
+
// Render STEPS. The runner writes its narration in English (it has no request
|
|
98
|
+
// locale), but each event also carries a machine `code`, so a Turkish chat can
|
|
99
|
+
// read the flow in Turkish instead of in the runner's English. An event whose
|
|
100
|
+
// code we have no label for falls back to the server's own sentence — which is
|
|
101
|
+
// why the set below can grow without the widget ever showing a blank line.
|
|
102
|
+
jobEvCancelled: "Cancelled",
|
|
103
|
+
jobEvCancelledBeforeStart: "Cancelled before it started",
|
|
104
|
+
jobEvInterrupted: "Interrupted by a restart — not retried automatically",
|
|
105
|
+
// Proposal confirm cards
|
|
106
|
+
// The SEVEN write tools that used to hit the generic English fallback
|
|
107
|
+
// ("Apply this change?") — including generate_report, the most expensive
|
|
108
|
+
// confirm in the product. The widget's contract is that visible copy lives
|
|
109
|
+
// here so a host can translate it; a `??` literal in the render path is
|
|
110
|
+
// outside that contract and untranslatable by construction.
|
|
111
|
+
/**
|
|
112
|
+
* The card title for a write proposal the host has not named.
|
|
113
|
+
*
|
|
114
|
+
* The fifteen sgiant-specific titles that sat beside this — and the six
|
|
115
|
+
* report-card labels — moved to @sgiant/ai-apply on 2026-09-02, along with
|
|
116
|
+
* the branches that used them. A package a stranger installs should not ship
|
|
117
|
+
* one company's tool vocabulary. Hosts pass their own via `proposalTitles`.
|
|
118
|
+
*/
|
|
119
|
+
proposalGeneric: "Apply this change?",
|
|
120
|
+
// The generate_report confirm card. These were four hardcoded English lines
|
|
121
|
+
// in `proposalSummary` — on a card the user reads before spending minutes of
|
|
122
|
+
// model time, in a widget whose whole contract is that visible copy lives
|
|
123
|
+
// here so it can be translated.
|
|
124
|
+
artifactsTitle: "This chat's files:",
|
|
125
|
+
artifactSave: "Save",
|
|
126
|
+
artifactSaving: "Saving…",
|
|
127
|
+
apply: "Apply",
|
|
128
|
+
dismiss: "Dismiss",
|
|
129
|
+
applying: "Applying…",
|
|
130
|
+
applied: "Applied",
|
|
131
|
+
openReport: "Open the report",
|
|
132
|
+
tryAgain: "Try again",
|
|
133
|
+
// History panel
|
|
134
|
+
close: "Close",
|
|
135
|
+
loading: "Loading…",
|
|
136
|
+
noConversations: "No past conversations yet.",
|
|
137
|
+
untitledConversation: "Untitled conversation",
|
|
138
|
+
star: "Star this conversation",
|
|
139
|
+
unstar: "Unstar",
|
|
140
|
+
historyLoadFailed: "Couldn't load history — try again.",
|
|
141
|
+
bucketToday: "Today",
|
|
142
|
+
bucketYesterday: "Yesterday",
|
|
143
|
+
bucketWeek: "Earlier this week",
|
|
144
|
+
bucketMonth: "This month",
|
|
145
|
+
bucketOlder: "Older",
|
|
146
|
+
// Lead form / preview / action chips
|
|
147
|
+
submit: "Submit",
|
|
148
|
+
sending: "Sending…",
|
|
149
|
+
/** Why a form's Send, or a proposal card's Apply, refused to go through. */
|
|
150
|
+
requiredFields: "Please fill in the highlighted fields first.",
|
|
151
|
+
done: "Done ✓",
|
|
152
|
+
preview: "Preview",
|
|
153
|
+
otherOption: "+ Other…",
|
|
154
|
+
confirm: "Confirm",
|
|
155
|
+
cancel: "Cancel",
|
|
156
|
+
// Error state
|
|
157
|
+
errorSnag: "{name} hit a snag and couldn't answer. Please try again.",
|
|
158
|
+
reportIssue: "Report issue",
|
|
159
|
+
reporting: "Reporting…",
|
|
160
|
+
reported: "Reported ✓ — our team will look into it",
|
|
161
|
+
reportFailed: "Couldn't report — try later",
|
|
162
|
+
// Quality prompt (#299) — the widget ASKING, because the whole signal was
|
|
163
|
+
// passive on surfaces where the control was invisible or absent.
|
|
164
|
+
//
|
|
165
|
+
// The two triggers deliberately ask DIFFERENT questions. A slow answer that
|
|
166
|
+
// was excellent, prompted with "was this helpful?", teaches us "slow = bad",
|
|
167
|
+
// which we already knew. So a long wait asks about the WAIT, and a failed
|
|
168
|
+
// turn asks about the GOAL.
|
|
169
|
+
qualitySlowTitle: "That took a while — was the answer worth it?",
|
|
170
|
+
qualityFailedTitle: "That didn't work — what were you trying to do?",
|
|
171
|
+
qualityReasonPlaceholder: "Anything you'd add? (optional)",
|
|
172
|
+
qualityFailedPlaceholder: "What were you trying to do?",
|
|
173
|
+
qualitySend: "Send",
|
|
174
|
+
qualityDismiss: "No thanks",
|
|
175
|
+
qualityThanks: "Thanks — noted ✓",
|
|
176
|
+
// Free-token meter. Shown ONLY when `signupUrl` is set, i.e. exactly on the
|
|
177
|
+
// anonymous surfaces — the marketing visitor chat and the public demo — both
|
|
178
|
+
// of which serve Turkish. These three were hardcoded English, so a Turkish
|
|
179
|
+
// visitor read "60,000 free tokens left" under a Turkish conversation.
|
|
180
|
+
meterTokensLeft: "{count} free tokens left",
|
|
181
|
+
meterFreePreview: "Free preview",
|
|
182
|
+
meterUsedThisSession: "{count} used this session",
|
|
183
|
+
// Signup CTA (anonymous surfaces)
|
|
184
|
+
signupCta: "Sign up — 14 days free",
|
|
185
|
+
// Composed UI cards ([[ui:…]]) — the four states the widget colours. Any
|
|
186
|
+
// OTHER status the model writes is shown in its own words, untranslated,
|
|
187
|
+
// because only these four are ours to name.
|
|
188
|
+
uiStatusPending: "Waiting",
|
|
189
|
+
uiStatusRunning: "Working…",
|
|
190
|
+
uiStatusReady: "Ready",
|
|
191
|
+
uiStatusFailed: "Failed",
|
|
192
|
+
/** A tile whose media hasn't been produced yet — the space is deliberately
|
|
193
|
+
* kept so the card doesn't reflow when the picture lands. */
|
|
194
|
+
uiMediaPending: "Not made yet",
|
|
195
|
+
/** A tile whose media id resolved to nothing (deleted, or not this account's).
|
|
196
|
+
* Said plainly, because a blank tile reads as a broken product. */
|
|
197
|
+
uiMediaMissing: "Unavailable",
|
|
198
|
+
/** Carousel paging controls on a composed card. */
|
|
199
|
+
prev: "Previous",
|
|
200
|
+
next: "Next",
|
|
201
|
+
/** ACTION CHIPS — the in-chat "open this page / run this" affordances.
|
|
202
|
+
* These were template literals built inline, so they had no key at all and
|
|
203
|
+
* a host could not translate them however hard it tried: a fully Turkish
|
|
204
|
+
* session still read "Opening Billing…", "Billing ✓", "Couldn't open
|
|
205
|
+
* Billing". `{label}` is the action's own name, which the host localises. */
|
|
206
|
+
actionOpening: "Opening {label}…",
|
|
207
|
+
actionDone: "{label} ✓",
|
|
208
|
+
actionOpenFailed: "Couldn't open {label}",
|
|
209
|
+
actionRunFailed: "Couldn't run {label}",
|
|
210
|
+
actionRetry: "{label} — try again",
|
|
211
|
+
/** Outcomes of an action the HOST performed on the page behind the chat. */
|
|
212
|
+
actionShownOnPage: "Shown on the page",
|
|
213
|
+
actionDoneOnPage: "Done on the page",
|
|
214
|
+
actionPageFailed: "Couldn't do that on the page",
|
|
215
|
+
actionOpened: "Opened",
|
|
216
|
+
/** A thread the transcript endpoint would not return. */
|
|
217
|
+
threadOpenFailed: "Couldn't open that conversation.",
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Build the widget's `labels` bag from a host translator (react-i18next's `t`).
|
|
221
|
+
* Each label resolves the `chatWidget.<key>` locale key, defaulting to the
|
|
222
|
+
* English string in WIDGET_LABELS. Call once per (re-)mount so the widget picks
|
|
223
|
+
* up the active language.
|
|
224
|
+
*/
|
|
225
|
+
export function resolveWidgetLabels(t) {
|
|
226
|
+
const out = {};
|
|
227
|
+
for (const k of Object.keys(WIDGET_LABELS)) {
|
|
228
|
+
out[k] = t(`chatWidget.${k}`, WIDGET_LABELS[k]);
|
|
229
|
+
}
|
|
230
|
+
return out;
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labels.js","sourceRoot":"","sources":["../src/labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,6DAA6D;IAC7D,eAAe,EAAE,MAAM;IACvB,mBAAmB,EAAE,mBAAmB;IACxC,kBAAkB,EAChB,mFAAmF;IACrF,kBAAkB;IAClB,UAAU,EAAE,aAAa;IACzB,gBAAgB,EAAE,8BAA8B;IAChD,SAAS,EAAE,aAAa;IACxB,OAAO,EAAE,UAAU;IACnB,iBAAiB,EAAE,oBAAoB;IACvC,4EAA4E;IAC5E,eAAe,EAAE,YAAY;IAC7B;iEAC6D;IAC7D,oBAAoB,EAClB,+EAA+E;IACjF,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,cAAc;IAC3B,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,aAAa;IACzB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,mBAAmB;IAChC,SAAS,EAAE,YAAY;IACvB,YAAY,EAAE,cAAc;IAC5B,uBAAuB;IACvB,EAAE,EAAE,IAAI;IACR,GAAG,EAAE,KAAK;IACV,YAAY,EAAE,sBAAsB;IACpC,gBAAgB,EAAE,wBAAwB;IAC1C,oBAAoB,EAAE,mCAAmC;IACzD,aAAa,EAAE,qDAAqD;IACpE,UAAU,EAAE,6DAA6D;IACzE,OAAO,EAAE,sCAAsC;IAC/C,UAAU,EAAE,sBAAsB;IAClC,iBAAiB,EAAE,kBAAkB;IACrC,iBAAiB,EAAE,oBAAoB;IACvC,WAAW,EAAE,4CAA4C;IACzD,YAAY,EAAE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
|
2
|
+
* The constants this widget used to import from `@sgiant/shared`, inlined.
|
|
3
|
+
*
|
|
4
|
+
* #306 requires the published core to have ZERO `@sgiant/*` runtime
|
|
5
|
+
* dependencies — a stranger installing the widget from npm cannot resolve a
|
|
6
|
+
* package that lives in our private registry, and three numbers are not a
|
|
7
|
+
* reason to make them try.
|
|
8
|
+
*
|
|
9
|
+
* BUT inlining is the exact move that created the bug `@sgiant/shared`'s
|
|
10
|
+
* `chat-attachment-limits.ts` was written to end: the client caps and the api's
|
|
11
|
+
* turn-time caps were four independent literals, so a 10 MB PNG passed every
|
|
12
|
+
* client check, uploaded fine, showed as a chip, and was silently dropped when
|
|
13
|
+
* the turn resolved it.
|
|
14
|
+
*
|
|
15
|
+
* So the copy is gated instead of trusted: a drift test in the host repo
|
|
16
|
+
* asserts every value here equals its `@sgiant/shared` original. The test is a
|
|
17
|
+
* monorepo devDependency, so it costs the published package nothing and still
|
|
18
|
+
* fails the build the moment the two drift.
|
|
19
|
+
*
|
|
20
|
+
* If you change a number here, change it in `@sgiant/shared` too — or rather,
|
|
21
|
+
* change it there and let the test tell you about this file.
|
|
22
|
+
*/
|
|
23
|
+
/** Attachments per message (composer slots AND turn-time resolution). */
|
|
24
|
+
export declare const CHAT_ATTACHMENT_MAX_COUNT = 6;
|
|
25
|
+
/** Client-side transport cap per file. */
|
|
26
|
+
export declare const CHAT_ATTACHMENT_MAX_BYTES: number;
|
|
27
|
+
/** Transport cap for an attached VIDEO or AUDIO file — much larger, because
|
|
28
|
+
* 25 MB is a document number and a 30-second 1080p phone clip is already past
|
|
29
|
+
* it. A clip is stored as an asset and referenced BY ID, never sent as bytes. */
|
|
30
|
+
export declare const CHAT_ATTACHMENT_MAX_AV_BYTES: number;
|
|
31
|
+
/** The locale tags the host may pass. Was `import type { Locale }` from
|
|
32
|
+
* `@sgiant/shared`; a type import erases at runtime but still puts the package
|
|
33
|
+
* in the manifest, which is what publishing reads. */
|
|
34
|
+
export type Locale = "en" | "tr";
|
|
35
|
+
/**
|
|
36
|
+
* The six motion custom properties the stylesheet reads, previously
|
|
37
|
+
* `motionCssVars()` from `@sgiant/tokens`.
|
|
38
|
+
*
|
|
39
|
+
* Kept as a function with the same shape so the call site is unchanged, and
|
|
40
|
+
* gated by the same drift test.
|
|
41
|
+
*/
|
|
42
|
+
export declare function motionCssVars(): string;
|
|
43
|
+
//# sourceMappingURL=limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,yEAAyE;AACzE,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,0CAA0C;AAC1C,eAAO,MAAM,yBAAyB,QAAmB,CAAC;AAE1D;;kFAEkF;AAClF,eAAO,MAAM,4BAA4B,QAAoB,CAAC;AAE9D;;uDAEuD;AACvD,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjC;;;;;;GAMG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAStC"}
|
package/dist/limits.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The constants this widget used to import from `@sgiant/shared`, inlined.
|
|
3
|
+
*
|
|
4
|
+
* #306 requires the published core to have ZERO `@sgiant/*` runtime
|
|
5
|
+
* dependencies — a stranger installing the widget from npm cannot resolve a
|
|
6
|
+
* package that lives in our private registry, and three numbers are not a
|
|
7
|
+
* reason to make them try.
|
|
8
|
+
*
|
|
9
|
+
* BUT inlining is the exact move that created the bug `@sgiant/shared`'s
|
|
10
|
+
* `chat-attachment-limits.ts` was written to end: the client caps and the api's
|
|
11
|
+
* turn-time caps were four independent literals, so a 10 MB PNG passed every
|
|
12
|
+
* client check, uploaded fine, showed as a chip, and was silently dropped when
|
|
13
|
+
* the turn resolved it.
|
|
14
|
+
*
|
|
15
|
+
* So the copy is gated instead of trusted: a drift test in the host repo
|
|
16
|
+
* asserts every value here equals its `@sgiant/shared` original. The test is a
|
|
17
|
+
* monorepo devDependency, so it costs the published package nothing and still
|
|
18
|
+
* fails the build the moment the two drift.
|
|
19
|
+
*
|
|
20
|
+
* If you change a number here, change it in `@sgiant/shared` too — or rather,
|
|
21
|
+
* change it there and let the test tell you about this file.
|
|
22
|
+
*/
|
|
23
|
+
/** Attachments per message (composer slots AND turn-time resolution). */
|
|
24
|
+
export const CHAT_ATTACHMENT_MAX_COUNT = 6;
|
|
25
|
+
/** Client-side transport cap per file. */
|
|
26
|
+
export const CHAT_ATTACHMENT_MAX_BYTES = 25 * 1024 * 1024;
|
|
27
|
+
/** Transport cap for an attached VIDEO or AUDIO file — much larger, because
|
|
28
|
+
* 25 MB is a document number and a 30-second 1080p phone clip is already past
|
|
29
|
+
* it. A clip is stored as an asset and referenced BY ID, never sent as bytes. */
|
|
30
|
+
export const CHAT_ATTACHMENT_MAX_AV_BYTES = 100 * 1024 * 1024;
|
|
31
|
+
/**
|
|
32
|
+
* The six motion custom properties the stylesheet reads, previously
|
|
33
|
+
* `motionCssVars()` from `@sgiant/tokens`.
|
|
34
|
+
*
|
|
35
|
+
* Kept as a function with the same shape so the call site is unchanged, and
|
|
36
|
+
* gated by the same drift test.
|
|
37
|
+
*/
|
|
38
|
+
export function motionCssVars() {
|
|
39
|
+
return [
|
|
40
|
+
`--duration-fast: 150ms;`,
|
|
41
|
+
`--duration-base: 300ms;`,
|
|
42
|
+
`--duration-slow: 600ms;`,
|
|
43
|
+
`--ease-out: cubic-bezier(0.22, 1, 0.36, 1);`,
|
|
44
|
+
`--ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);`,
|
|
45
|
+
`--ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);`,
|
|
46
|
+
].join("\n");
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,yEAAyE;AACzE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAE3C,0CAA0C;AAC1C,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAE1D;;kFAEkF;AAClF,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAO9D;;;;;;GAMG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO;QACL,yBAAyB;QACzB,yBAAyB;QACzB,yBAAyB;QACzB,6CAA6C;QAC7C,gDAAgD;QAChD,gDAAgD;KACjD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal, dependency-free, XSS-safe Markdown → HTML for the embeddable chat
|
|
3
|
+
* widget's assistant bubbles — the FALLBACK renderer.
|
|
4
|
+
*
|
|
5
|
+
* In-app React hosts pass `renderMarkdown` (our real @sgiant/ui <Markdown>) and
|
|
6
|
+
* this is never used there. But the widget also ships as ZERO-dependency vanilla
|
|
7
|
+
* JS and embeds on third-party sites (the marketing onboarding bot), where React
|
|
8
|
+
* isn't available — so this covers the subset the assistant actually emits:
|
|
9
|
+
* headings, bold / italic / strikethrough, inline + fenced code, links, ordered
|
|
10
|
+
* / unordered lists, blockquotes, GFM tables, horizontal rules and paragraphs.
|
|
11
|
+
*
|
|
12
|
+
* SECURITY: every input is HTML-escaped BEFORE any markup is added, code spans
|
|
13
|
+
* are tokenised out (NUL-delimited sentinels, so they can't collide with text)
|
|
14
|
+
* before inline processing, and link URLs are sanitised (http/https/mailto or
|
|
15
|
+
* app-relative only). No raw HTML or `javascript:` URL can pass through — the
|
|
16
|
+
* model's output is untrusted text, never markup.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Render a small, safe subset of Markdown to an HTML string, to be injected into
|
|
20
|
+
* a widget bubble whose descendant CSS styles the tags.
|
|
21
|
+
*/
|
|
22
|
+
export declare function renderMarkdown(src: string): string;
|
|
23
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAmEH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAmJlD"}
|
package/dist/markdown.js
ADDED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,QAAQ,GAA2B;IACvC,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,OAAO;CACb,CAAC;AAEF,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAW,CAAC,CAAC;AAC7D,CAAC;AAED,2EAA2E;AAC3E,SAAS,OAAO,CAAC,GAAW;IAC1B,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IACrB,IAAI,yBAAyB,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IAChD,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC,sCAAsC;IACrE,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,SAAS,MAAM,CAAC,GAAW;IACzB,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,yEAAyE;IAC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istant message: the ‹n/m› branch
|
|
4
|
+
* navigator and the up/down vote pair.
|
|
5
|
+
*
|
|
6
|
+
* Both are pure DOM builders — they read no widget state and write none. They
|
|
7
|
+
* sat inside the 6,051-line closure only because that is where they were
|
|
8
|
+
* written (`#320`), and they are the shape that actually moves out of it: the
|
|
9
|
+
* measurement on that issue put them at two closure bindings each, against 56
|
|
10
|
+
* for `send()` and 28 for the job cluster.
|
|
11
|
+
*
|
|
12
|
+
* THE THREAD ID IS A GETTER, AND THAT IS THE WHOLE REASON THIS IS A FACTORY.
|
|
13
|
+
*
|
|
14
|
+
* `buildVoteButtons` reads the thread id inside the CLICK handler, not while
|
|
15
|
+
* building. In the closure that was automatic — `threadId` is a `let` the widget
|
|
16
|
+
* reassigns when the server names a thread, and a vote cast later reads whatever
|
|
17
|
+
* it holds then. Taking it as a plain parameter here would capture the value at
|
|
18
|
+
* BUILD time, so a message rendered before the thread was named would post its
|
|
19
|
+
* vote against the wrong id — or an empty one — and nothing would fail loudly:
|
|
20
|
+
* the request succeeds, the vote lands on nothing, and the quality signal
|
|
21
|
+
* `#299` exists to collect goes quietly missing.
|
|
22
|
+
*
|
|
23
|
+
* A getter keeps the read where it was. The rest of the dependencies are fixed
|
|
24
|
+
* for the widget's lifetime and are captured once, which is what lets both
|
|
25
|
+
* bodies move byte for byte.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createMessageChrome(deps: {
|
|
28
|
+
/** Navigate to a sibling version. Called on click, so the reference is enough. */
|
|
29
|
+
switchBranch: (leaf: string) => void | Promise<void>;
|
|
30
|
+
/** Read the CURRENT thread id — see the note above; do not pass a value. */
|
|
31
|
+
getThreadId: () => string | undefined;
|
|
32
|
+
vote?: (input: {
|
|
33
|
+
threadId: string;
|
|
34
|
+
messageId: string;
|
|
35
|
+
value: 1 | -1 | 0;
|
|
36
|
+
model?: string;
|
|
37
|
+
reason?: string;
|
|
38
|
+
}) => Promise<void>;
|
|
39
|
+
voteUpLabel?: string;
|
|
40
|
+
voteDownLabel?: string;
|
|
41
|
+
}): {
|
|
42
|
+
buildBranchNav: (branch: BranchNav) => HTMLElement;
|
|
43
|
+
buildVoteButtons: (messageId: string, model?: string) => HTMLElement;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=message-chrome.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-chrome.d.ts","sourceRoot":"","sources":["../src/message-chrome.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,kFAAkF;IAClF,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,4EAA4E;IAC5E,WAAW,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACtC,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;6BAGiC,SAAS,KAAG,WAAW;kCA4BlB,MAAM,UAAU,MAAM,KAAG,WAAW;EAgD1E"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { el } from "./dom.js";
|
|
2
|
+
import { ICON_CHEV_L, ICON_CHEV_R, ICON_THUMB_DOWN, ICON_THUMB_UP, } from "./icons.js";
|
|
3
|
+
import { PREFIX } from "./prefix.js";
|
|
4
|
+
/**
|
|
5
|
+
* The two controls that hang off a single assistant message: the ‹n/m› branch
|
|
6
|
+
* navigator and the up/down vote pair.
|
|
7
|
+
*
|
|
8
|
+
* Both are pure DOM builders — they read no widget state and write none. They
|
|
9
|
+
* sat inside the 6,051-line closure only because that is where they were
|
|
10
|
+
* written (`#320`), and they are the shape that actually moves out of it: the
|
|
11
|
+
* measurement on that issue put them at two closure bindings each, against 56
|
|
12
|
+
* for `send()` and 28 for the job cluster.
|
|
13
|
+
*
|
|
14
|
+
* THE THREAD ID IS A GETTER, AND THAT IS THE WHOLE REASON THIS IS A FACTORY.
|
|
15
|
+
*
|
|
16
|
+
* `buildVoteButtons` reads the thread id inside the CLICK handler, not while
|
|
17
|
+
* building. In the closure that was automatic — `threadId` is a `let` the widget
|
|
18
|
+
* reassigns when the server names a thread, and a vote cast later reads whatever
|
|
19
|
+
* it holds then. Taking it as a plain parameter here would capture the value at
|
|
20
|
+
* BUILD time, so a message rendered before the thread was named would post its
|
|
21
|
+
* vote against the wrong id — or an empty one — and nothing would fail loudly:
|
|
22
|
+
* the request succeeds, the vote lands on nothing, and the quality signal
|
|
23
|
+
* `#299` exists to collect goes quietly missing.
|
|
24
|
+
*
|
|
25
|
+
* A getter keeps the read where it was. The rest of the dependencies are fixed
|
|
26
|
+
* for the widget's lifetime and are captured once, which is what lets both
|
|
27
|
+
* bodies move byte for byte.
|
|
28
|
+
*/
|
|
29
|
+
export function createMessageChrome(deps) {
|
|
30
|
+
const { switchBranch, getThreadId, vote, voteUpLabel, voteDownLabel } = deps;
|
|
31
|
+
function buildBranchNav(branch) {
|
|
32
|
+
const nav = el("div", `${PREFIX}-branchnav`);
|
|
33
|
+
const prev = el("button", `${PREFIX}-branch-btn`);
|
|
34
|
+
prev.type = "button";
|
|
35
|
+
prev.setAttribute("aria-label", "Previous version");
|
|
36
|
+
prev.innerHTML = ICON_CHEV_L;
|
|
37
|
+
prev.disabled = !branch.prevLeaf;
|
|
38
|
+
if (branch.prevLeaf) {
|
|
39
|
+
const leaf = branch.prevLeaf;
|
|
40
|
+
prev.addEventListener("click", () => void switchBranch(leaf));
|
|
41
|
+
}
|
|
42
|
+
const count = el("span", `${PREFIX}-branch-count`);
|
|
43
|
+
count.textContent = `${branch.index}/${branch.count}`;
|
|
44
|
+
const next = el("button", `${PREFIX}-branch-btn`);
|
|
45
|
+
next.type = "button";
|
|
46
|
+
next.setAttribute("aria-label", "Next version");
|
|
47
|
+
next.innerHTML = ICON_CHEV_R;
|
|
48
|
+
next.disabled = !branch.nextLeaf;
|
|
49
|
+
if (branch.nextLeaf) {
|
|
50
|
+
const leaf = branch.nextLeaf;
|
|
51
|
+
next.addEventListener("click", () => void switchBranch(leaf));
|
|
52
|
+
}
|
|
53
|
+
nav.appendChild(prev);
|
|
54
|
+
nav.appendChild(count);
|
|
55
|
+
nav.appendChild(next);
|
|
56
|
+
return nav;
|
|
57
|
+
}
|
|
58
|
+
function buildVoteButtons(messageId, model) {
|
|
59
|
+
const wrap = el("div", `${PREFIX}-votes`);
|
|
60
|
+
let cur = 0;
|
|
61
|
+
const up = el("button", `${PREFIX}-msgact ${PREFIX}-vote`);
|
|
62
|
+
const down = el("button", `${PREFIX}-msgact ${PREFIX}-vote`);
|
|
63
|
+
up.type = "button";
|
|
64
|
+
down.type = "button";
|
|
65
|
+
up.setAttribute("aria-label", voteUpLabel ?? "Helpful");
|
|
66
|
+
down.setAttribute("aria-label", voteDownLabel ?? "Not helpful");
|
|
67
|
+
up.title = voteUpLabel ?? "Helpful";
|
|
68
|
+
down.title = voteDownLabel ?? "Not helpful";
|
|
69
|
+
up.innerHTML = ICON_THUMB_UP;
|
|
70
|
+
down.innerHTML = ICON_THUMB_DOWN;
|
|
71
|
+
const paint = () => {
|
|
72
|
+
up.classList.toggle(`${PREFIX}-vote-on`, cur === 1);
|
|
73
|
+
down.classList.toggle(`${PREFIX}-vote-on`, cur === -1);
|
|
74
|
+
};
|
|
75
|
+
const cast = (next) => {
|
|
76
|
+
if (!vote)
|
|
77
|
+
return;
|
|
78
|
+
const value = (cur === next ? 0 : next);
|
|
79
|
+
const prev = cur;
|
|
80
|
+
cur = value;
|
|
81
|
+
paint();
|
|
82
|
+
// messageId is globally unique; the current threadId scopes the vote.
|
|
83
|
+
void vote({
|
|
84
|
+
threadId: getThreadId() ?? "",
|
|
85
|
+
messageId,
|
|
86
|
+
value,
|
|
87
|
+
...(model ? { model } : {}),
|
|
88
|
+
}).catch(() => {
|
|
89
|
+
cur = prev;
|
|
90
|
+
paint();
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
up.addEventListener("click", () => cast(1));
|
|
94
|
+
down.addEventListener("click", () => cast(-1));
|
|
95
|
+
wrap.appendChild(up);
|
|
96
|
+
wrap.appendChild(down);
|
|
97
|
+
return wrap;
|
|
98
|
+
}
|
|
99
|
+
return { buildBranchNav, buildVoteButtons };
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=message-chrome.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-chrome.js","sourceRoot":"","sources":["../src/message-chrome.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EACL,WAAW,EACX,WAAW,EACX,eAAe,EACf,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAcnC;IACC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;IAE7E,SAAS,cAAc,CAAC,MAAiB;QACvC,MAAM,GAAG,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,MAAM,YAAY,CAAC,CAAC;QAC7C,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,EAAE,GAAG,MAAM,aAAa,CAAsB,CAAC;QACvE,IAAI,CAAC,IAAI,GAAG,QAAQ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,GAAG,CAAC;YACjB,GAAG,GAAG,KAAK,CAAC;YACZ,KAAK,EAAE,CAAC;YACR,sEAAsE;YACtE,KAAK,IAAI,CAAC;gBACR,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE;gBAC7B,SAAS;gBACT,KAAK;gBACL,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC5B,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;gBACZ,GAAG,GAAG,IAAI,CAAC;gBACX,KAAK,EAAE,CAAC;YACV,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QACF,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5C,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/C,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QACrB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TWO DECISIONS THE APP PANE MAKES, extracted so they can be checked.
|
|
3
|
+
*
|
|
4
|
+
* Both live inside `createAiChatWidget`'s closure in the real widget, where
|
|
5
|
+
* they are unreachable from a test — and both are the kind of rule that fails
|
|
6
|
+
* politely: get them wrong and the pane either never follows a long operation
|
|
7
|
+
* (the feature silently does nothing) or follows it too eagerly (it yanks a
|
|
8
|
+
* reader off the page they chose, repeatedly, on every poll). Neither shows up
|
|
9
|
+
* as an error.
|
|
10
|
+
*/
|
|
11
|
+
/** Same-path test used for both decisions. A query string is a filter within a
|
|
12
|
+
* page, not a different destination; a trailing slash is not a destination
|
|
13
|
+
* either. */
|
|
14
|
+
export declare function samePanePath(a: string | null | undefined, b: string | null | undefined): boolean;
|
|
15
|
+
export interface AutoNavigateInput {
|
|
16
|
+
/** Advanced view is open. There is no pane to move otherwise, and moving the
|
|
17
|
+
* whole PAGE because a background job started is a different feature. */
|
|
18
|
+
advanced: boolean;
|
|
19
|
+
/** The host wired `getAdvancedUrl` — without it there is no embed URL. */
|
|
20
|
+
canNavigate: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The user CONFIRMED this operation in this session — they pressed the button
|
|
23
|
+
* that started it, in this widget, just now.
|
|
24
|
+
*
|
|
25
|
+
* The other three conditions all ask whether following would be RUDE. This
|
|
26
|
+
* one asks whether the operation is the user's at all. A tracked job outlives
|
|
27
|
+
* the tab: it is written to localStorage so a running import survives a
|
|
28
|
+
* refresh, and it is also re-discovered from the server listing so work
|
|
29
|
+
* started on another device shows up here. Neither of those is a thing the
|
|
30
|
+
* person in front of the screen just asked for, and "advanced view was opened"
|
|
31
|
+
* is not consent to be sent to a page some other tab started building.
|
|
32
|
+
*/
|
|
33
|
+
userConfirmedThisSession: boolean;
|
|
34
|
+
/** The user has driven the frame themselves since this session began. */
|
|
35
|
+
userDriven: boolean;
|
|
36
|
+
/** This operation has already been followed once. */
|
|
37
|
+
alreadyFollowed: boolean;
|
|
38
|
+
/** The path to follow to, as the model/host supplied it. */
|
|
39
|
+
path: string | null | undefined;
|
|
40
|
+
/** Where the pane is now — skip the reload if it is already there. */
|
|
41
|
+
currentPath?: string | null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Should the pane follow a long operation to its live page?
|
|
45
|
+
*
|
|
46
|
+
* Every `false` here is a way this becomes obnoxious rather than helpful, and
|
|
47
|
+
* the third one is the one that bites hardest: a report card polls every couple
|
|
48
|
+
* of seconds, so a decision that does not remember it already followed would
|
|
49
|
+
* reload the page continuously — turning "watch it build" into a surface that
|
|
50
|
+
* cannot be read at all.
|
|
51
|
+
*/
|
|
52
|
+
export declare function shouldAutoNavigate(i: AutoNavigateInput): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Should the chat column collapse its narration to one line?
|
|
55
|
+
*
|
|
56
|
+
* True exactly when the pane is showing the same run — the owner's decision for
|
|
57
|
+
* advanced mode. The report page owns the detail (it has the stage rail and it
|
|
58
|
+
* is the authority on stage), and two renderings of one job on one screen is
|
|
59
|
+
* the divergence advanced view makes visible. When the pane is elsewhere the
|
|
60
|
+
* chat is the ONLY account of what is happening, so it narrates in full.
|
|
61
|
+
*/
|
|
62
|
+
export declare function shouldCollapseNarration(i: {
|
|
63
|
+
advanced: boolean;
|
|
64
|
+
livePath: string | null | undefined;
|
|
65
|
+
currentPath: string | null | undefined;
|
|
66
|
+
}): boolean;
|
|
67
|
+
//# sourceMappingURL=pane-follow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pane-follow.d.ts","sourceRoot":"","sources":["../src/pane-follow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;cAEc;AACd,wBAAgB,YAAY,CAC1B,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC5B,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC3B,OAAO,CAOT;AAED,MAAM,WAAW,iBAAiB;IAChC;8EAC0E;IAC1E,QAAQ,EAAE,OAAO,CAAC;IAClB,0EAA0E;IAC1E,WAAW,EAAE,OAAO,CAAC;IACrB;;;;;;;;;;;OAWG;IACH,wBAAwB,EAAE,OAAO,CAAC;IAClC,yEAAyE;IACzE,UAAU,EAAE,OAAO,CAAC;IACpB,qDAAqD;IACrD,eAAe,EAAE,OAAO,CAAC;IACzB,4DAA4D;IAC5D,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAChC,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAUhE;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE;IACzC,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACpC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACxC,GAAG,OAAO,CAGV"}
|