@supersolutions/super-chat-ui-core 0.0.0-stage → 0.1.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 +201 -0
- package/NOTICE +14 -0
- package/README.md +26 -2
- package/dist/index.d.ts +75 -0
- package/dist/index.js +353 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 SUPER SOLUTION LABS INC
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
superchat
|
|
2
|
+
Copyright 2026 SUPER SOLUTION LABS INC
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @supersolutions/super-chat-ui-core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Framework-free helpers that every superchat UI binding shares, so a Vue, Svelte or native
|
|
4
|
+
binding does not have to reimplement them:
|
|
5
|
+
|
|
6
|
+
- `markdown.ts` — `renderMarkdown`, incremental `renderMarkdownStream` and
|
|
7
|
+
`renderMarkdownWithAnchors` (a source-span map for quoting).
|
|
8
|
+
- `format.ts` — `formatValue`, `formatDelta`, `toneClass`, `deltaTone` for card values.
|
|
9
|
+
- `export.ts` — `threadToMarkdown`, `downloadThread`.
|
|
10
|
+
|
|
11
|
+
No React, no DOM framework. Part of the [superchat](../../README.md) monorepo. The React
|
|
12
|
+
components live in [`@supersolutions/super-chat-ui`](../ui/README.md); the shared stylesheet still
|
|
13
|
+
ships with that package for now.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @supersolutions/super-chat-core @supersolutions/super-chat-ui-core
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Develop
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pnpm --filter @supersolutions/super-chat-ui-core build
|
|
25
|
+
pnpm --filter @supersolutions/super-chat-ui-core typecheck
|
|
26
|
+
pnpm vitest run packages/ui-core
|
|
27
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { CardValueFormat, Message, MarkdownBlock } from '@supersolutions/super-chat-core';
|
|
2
|
+
|
|
3
|
+
declare function formatValue(value: unknown, format?: CardValueFormat): string;
|
|
4
|
+
declare function formatDelta(delta: number, format?: CardValueFormat): string;
|
|
5
|
+
declare const toneClass: (tone?: string) => string;
|
|
6
|
+
/** Positive is not always good — but for a delta with no stated tone it is the useful default. */
|
|
7
|
+
declare const deltaTone: (delta: number) => "positive" | "negative" | "neutral";
|
|
8
|
+
/**
|
|
9
|
+
* A URL that came from a model or a tool, made safe to put in an `href`: only http(s) links
|
|
10
|
+
* pass, anything else (`javascript:`, `data:`, `vbscript:`, a relative path that could be read
|
|
11
|
+
* as a scheme after whitespace tricks) comes back as `undefined` and the caller renders plain
|
|
12
|
+
* text. React 19 refuses `javascript:` hrefs itself, but this package supports React 18, which
|
|
13
|
+
* only warns and then navigates.
|
|
14
|
+
*/
|
|
15
|
+
declare function safeHref(url: string | undefined | null): string | undefined;
|
|
16
|
+
|
|
17
|
+
/** Render a thread as markdown. `title` becomes the H1 when given. */
|
|
18
|
+
declare function threadToMarkdown(messages: readonly Message[], title?: string): string;
|
|
19
|
+
/** Trigger a download of the thread as a `.md` file. */
|
|
20
|
+
declare function downloadThread(messages: readonly Message[], filename?: string, title?: string): void;
|
|
21
|
+
|
|
22
|
+
type AnchoredMarkdown = {
|
|
23
|
+
html: string;
|
|
24
|
+
/** Index-aligned with the `data-sc-block` attribute on the rendered HTML. */
|
|
25
|
+
blocks: MarkdownBlock[];
|
|
26
|
+
};
|
|
27
|
+
/** Render for the transcript: no anchors, because chat prose is not addressed. */
|
|
28
|
+
declare function renderMarkdown(src: string): string;
|
|
29
|
+
/** What renderMarkdownStream keeps between calls. Start from newMarkdownStream(). */
|
|
30
|
+
type MarkdownStream = {
|
|
31
|
+
/** The source the cached blocks were decided on; valid while the text starts with it. */
|
|
32
|
+
settled: string;
|
|
33
|
+
/** Rendered HTML of those blocks. */
|
|
34
|
+
html: string;
|
|
35
|
+
/** Where the block after them starts looking: the line after the last one. */
|
|
36
|
+
resume: number;
|
|
37
|
+
};
|
|
38
|
+
declare const newMarkdownStream: () => MarkdownStream;
|
|
39
|
+
/**
|
|
40
|
+
* renderMarkdown for text that grows while it is shown — always the same
|
|
41
|
+
* string renderMarkdown(src) returns, but blocks that can no longer change are
|
|
42
|
+
* rendered once and reused, so a streamed answer costs its open tail per
|
|
43
|
+
* frame instead of its whole length.
|
|
44
|
+
*
|
|
45
|
+
* Every block renders from its own source slice alone, so the only question
|
|
46
|
+
* is which blocks later text can still move. splitBlocks decides a block's
|
|
47
|
+
* extent from its own lines and, at most, the first line of the block after
|
|
48
|
+
* it: the blank line or fence opener that ends it, and for a list or quote the
|
|
49
|
+
* next non-blank line, which may continue it. Whether a line is blank, a fence
|
|
50
|
+
* opener or closer, a list item or a quote can change while it is the last,
|
|
51
|
+
* unterminated line — `1` becomes `1.`, a closing ``` becomes ```js, ``` gains
|
|
52
|
+
* a backtick and stops opening a fence, a blank line gets text. Every line
|
|
53
|
+
* before the last is final. So a block is settled once the block after it
|
|
54
|
+
* starts before the last line: a setext underline, a loose list's next item,
|
|
55
|
+
* a table's delimiter row or the rest of an open fence all belong to the
|
|
56
|
+
* block that is still open. (This renderer has no reference definitions,
|
|
57
|
+
* footnotes or raw HTML blocks, the other constructs that reach back.) And
|
|
58
|
+
* splitBlocks never looks behind the line it stands on, so splitting from the
|
|
59
|
+
* line after the settled blocks yields the same blocks the whole text would.
|
|
60
|
+
*
|
|
61
|
+
* Text that does not start with `stream.settled` — a new run, an edit — drops
|
|
62
|
+
* the cache and renders from scratch.
|
|
63
|
+
*/
|
|
64
|
+
declare function renderMarkdownStream(src: string, stream: MarkdownStream): string;
|
|
65
|
+
/**
|
|
66
|
+
* Render for a document previewer: every block carries `data-sc-block`, so a
|
|
67
|
+
* DOM selection resolves to a source span by walking up to the nearest one.
|
|
68
|
+
*
|
|
69
|
+
* Kept separate from renderMarkdown rather than added as an option, because
|
|
70
|
+
* assistant prose has nothing to address and the extra attributes would be
|
|
71
|
+
* noise in every message bubble.
|
|
72
|
+
*/
|
|
73
|
+
declare function renderMarkdownWithAnchors(src: string): AnchoredMarkdown;
|
|
74
|
+
|
|
75
|
+
export { type AnchoredMarkdown, type MarkdownStream, deltaTone, downloadThread, formatDelta, formatValue, newMarkdownStream, renderMarkdown, renderMarkdownStream, renderMarkdownWithAnchors, safeHref, threadToMarkdown, toneClass };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
// src/format.ts
|
|
2
|
+
var compact = new Intl.NumberFormat(void 0, { notation: "compact", maximumFractionDigits: 2 });
|
|
3
|
+
var plain = new Intl.NumberFormat(void 0, { maximumFractionDigits: 6 });
|
|
4
|
+
var pctWide = new Intl.NumberFormat(void 0, { maximumFractionDigits: 1, useGrouping: false });
|
|
5
|
+
var pctNarrow = new Intl.NumberFormat(void 0, { maximumFractionDigits: 2, useGrouping: false });
|
|
6
|
+
var percent = (n) => (Math.abs(n) < 1 ? pctNarrow : pctWide).format(n);
|
|
7
|
+
function formatValue(value, format = "text") {
|
|
8
|
+
if (value == null) return "\u2014";
|
|
9
|
+
switch (format) {
|
|
10
|
+
case "number": {
|
|
11
|
+
const n = Number(value);
|
|
12
|
+
if (!Number.isFinite(n)) return String(value);
|
|
13
|
+
return Math.abs(n) >= 1e5 ? compact.format(n) : plain.format(n);
|
|
14
|
+
}
|
|
15
|
+
case "currency": {
|
|
16
|
+
const n = Number(value);
|
|
17
|
+
if (!Number.isFinite(n)) return String(value);
|
|
18
|
+
const abs = Math.abs(n);
|
|
19
|
+
const digits = abs >= 1 ? 2 : abs >= 0.01 ? 4 : 8;
|
|
20
|
+
const min = abs >= 1e3 && Number.isInteger(n) ? 0 : 2;
|
|
21
|
+
return `$${n.toLocaleString(void 0, { minimumFractionDigits: min, maximumFractionDigits: Math.max(min, digits) })}`;
|
|
22
|
+
}
|
|
23
|
+
case "percent": {
|
|
24
|
+
const n = Number(value);
|
|
25
|
+
if (!Number.isFinite(n)) return String(value);
|
|
26
|
+
return `${percent(n)}%`;
|
|
27
|
+
}
|
|
28
|
+
case "bytes": {
|
|
29
|
+
const n = Number(value);
|
|
30
|
+
if (!Number.isFinite(n)) return String(value);
|
|
31
|
+
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
32
|
+
let i = 0;
|
|
33
|
+
let v = n;
|
|
34
|
+
while (v >= 1024 && i < units.length - 1) {
|
|
35
|
+
v /= 1024;
|
|
36
|
+
i += 1;
|
|
37
|
+
}
|
|
38
|
+
return `${v.toFixed(i === 0 ? 0 : 1)} ${units[i]}`;
|
|
39
|
+
}
|
|
40
|
+
case "duration": {
|
|
41
|
+
const ms = Number(value);
|
|
42
|
+
if (!Number.isFinite(ms)) return String(value);
|
|
43
|
+
if (ms < 1e3) return `${Math.round(ms)}ms`;
|
|
44
|
+
if (ms < 6e4) return `${(ms / 1e3).toFixed(1)}s`;
|
|
45
|
+
if (ms < 36e5) return `${Math.floor(ms / 6e4)}m ${Math.round(ms % 6e4 / 1e3)}s`;
|
|
46
|
+
return `${(ms / 36e5).toFixed(1)}h`;
|
|
47
|
+
}
|
|
48
|
+
case "datetime": {
|
|
49
|
+
const d = typeof value === "number" ? new Date(value) : new Date(String(value));
|
|
50
|
+
return Number.isNaN(d.getTime()) ? String(value) : d.toLocaleString();
|
|
51
|
+
}
|
|
52
|
+
case "code":
|
|
53
|
+
case "text":
|
|
54
|
+
default:
|
|
55
|
+
return typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function formatDelta(delta, format = "number") {
|
|
59
|
+
const sign = delta > 0 ? "+" : delta < 0 ? "\u2212" : "";
|
|
60
|
+
return `${sign}${formatValue(Math.abs(delta), format)}`;
|
|
61
|
+
}
|
|
62
|
+
var toneClass = (tone) => tone && tone !== "neutral" ? ` sc-tone--${tone}` : "";
|
|
63
|
+
var deltaTone = (delta) => delta > 0 ? "positive" : delta < 0 ? "negative" : "neutral";
|
|
64
|
+
function safeHref(url) {
|
|
65
|
+
if (typeof url !== "string") return void 0;
|
|
66
|
+
const trimmed = url.trim();
|
|
67
|
+
if (/[\u0000-\u001f\u007f]/.test(trimmed)) return void 0;
|
|
68
|
+
return /^https?:\/\/[^\s]+$/i.test(trimmed) ? trimmed : void 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/export.ts
|
|
72
|
+
function cardToMarkdown(spec) {
|
|
73
|
+
const kind = String(spec.kind ?? "unknown");
|
|
74
|
+
const title = spec.title ? `**${spec.title}**
|
|
75
|
+
|
|
76
|
+
` : "";
|
|
77
|
+
if (kind === "table" && Array.isArray(spec.columns) && Array.isArray(spec.rows)) {
|
|
78
|
+
const cols = spec.columns;
|
|
79
|
+
const rows = spec.rows;
|
|
80
|
+
const head = `| ${cols.map((c) => c.label).join(" | ")} |`;
|
|
81
|
+
const rule = `| ${cols.map(() => "---").join(" | ")} |`;
|
|
82
|
+
const body = rows.map((r) => `| ${cols.map((c) => String(r[c.key] ?? "")).join(" | ")} |`).join("\n");
|
|
83
|
+
return `${title}${head}
|
|
84
|
+
${rule}
|
|
85
|
+
${body}`;
|
|
86
|
+
}
|
|
87
|
+
if (kind === "markdown" && typeof spec.body === "string") return `${title}${spec.body}`;
|
|
88
|
+
if (kind === "code" && typeof spec.code === "string") {
|
|
89
|
+
return `${title}\`\`\`${spec.language ?? ""}
|
|
90
|
+
${spec.code}
|
|
91
|
+
\`\`\``;
|
|
92
|
+
}
|
|
93
|
+
if (kind === "callout" && typeof spec.body === "string") return `> ${title}${spec.body}`;
|
|
94
|
+
return `${title}\`\`\`json
|
|
95
|
+
${JSON.stringify(spec, null, 2)}
|
|
96
|
+
\`\`\``;
|
|
97
|
+
}
|
|
98
|
+
function partToMarkdown(part) {
|
|
99
|
+
switch (part.type) {
|
|
100
|
+
case "text":
|
|
101
|
+
return part.text;
|
|
102
|
+
case "reasoning":
|
|
103
|
+
return `<details><summary>Reasoning</summary>
|
|
104
|
+
|
|
105
|
+
${part.text}
|
|
106
|
+
|
|
107
|
+
</details>`;
|
|
108
|
+
case "tool-call":
|
|
109
|
+
return `- \`${part.name}(${JSON.stringify(part.input ?? {})})\``;
|
|
110
|
+
case "tool-result":
|
|
111
|
+
return part.failure ? `- \`${part.name}\` failed: ${part.failure}` : null;
|
|
112
|
+
case "image":
|
|
113
|
+
return "_(image)_";
|
|
114
|
+
case "file":
|
|
115
|
+
return `_(file: ${part.filename ?? "attachment"})_`;
|
|
116
|
+
case "artifact":
|
|
117
|
+
return part.kind.startsWith("card:") ? cardToMarkdown(part.data.spec ?? part.data) : null;
|
|
118
|
+
default:
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function threadToMarkdown(messages, title) {
|
|
123
|
+
const out = title ? [`# ${title}`, ""] : [];
|
|
124
|
+
for (const m of messages) {
|
|
125
|
+
if (m.role === "system") continue;
|
|
126
|
+
const body = m.parts.map(partToMarkdown).filter(Boolean).join("\n\n");
|
|
127
|
+
if (!body) continue;
|
|
128
|
+
const who = m.role === "user" ? "You" : m.role === "tool" ? "Tools" : "Assistant";
|
|
129
|
+
const when = m.createdAt ? ` \xB7 ${new Date(m.createdAt).toISOString().slice(0, 16).replace("T", " ")}` : "";
|
|
130
|
+
out.push(`## ${who}${when}`, "", body, "");
|
|
131
|
+
}
|
|
132
|
+
return out.join("\n").trimEnd() + "\n";
|
|
133
|
+
}
|
|
134
|
+
function downloadThread(messages, filename = "conversation.md", title) {
|
|
135
|
+
const blob = new Blob([threadToMarkdown(messages, title)], { type: "text/markdown;charset=utf-8" });
|
|
136
|
+
const url = URL.createObjectURL(blob);
|
|
137
|
+
const a = document.createElement("a");
|
|
138
|
+
a.href = url;
|
|
139
|
+
a.download = filename;
|
|
140
|
+
a.click();
|
|
141
|
+
requestAnimationFrame(() => URL.revokeObjectURL(url));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/markdown.ts
|
|
145
|
+
import { splitBlocks } from "@supersolutions/super-chat-core";
|
|
146
|
+
var MARKDOWN_SIGNIFICANT = /[`*_#[\]>~|-]/;
|
|
147
|
+
var ORDERED_ITEM = /^ {0,3}\d{1,9}[.)]\s/m;
|
|
148
|
+
var SETEXT_EQUALS = /\n {0,3}=+[ \t]*$/;
|
|
149
|
+
var isPlainProse = (raw) => !MARKDOWN_SIGNIFICANT.test(raw) && !ORDERED_ITEM.test(raw) && !SETEXT_EQUALS.test(raw);
|
|
150
|
+
var MAX_DEPTH = 4;
|
|
151
|
+
var escapeHtml = (s) => s.replace(/\0/g, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
152
|
+
var LINK = /\[([^\]]+)\]\((https?:\/\/(?:[^()\s]|\([^()\s]*\))+)\)/g;
|
|
153
|
+
var emphasize = (s) => s.replace(/~~([^~\n]+)~~/g, "<del>$1</del>").replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(/(^|[^*])\*([^*\n]+)\*/g, "$1<em>$2</em>");
|
|
154
|
+
function inline(raw) {
|
|
155
|
+
const spans = [];
|
|
156
|
+
const spanSource = [];
|
|
157
|
+
let s = escapeHtml(raw);
|
|
158
|
+
s = s.replace(/(`+)([\s\S]+?)\1(?!`)/g, (all, _ticks, body) => {
|
|
159
|
+
spans.push(body);
|
|
160
|
+
spanSource.push(all);
|
|
161
|
+
return `\0${spans.length - 1}\0`;
|
|
162
|
+
});
|
|
163
|
+
const links = [];
|
|
164
|
+
s = s.replace(LINK, (_all, text, url) => {
|
|
165
|
+
const literal = url.replace(/\0(\d+)\0/g, (_m, i) => spanSource[Number(i)]);
|
|
166
|
+
links.push({ text, url: literal });
|
|
167
|
+
return `\0L${links.length - 1}\0`;
|
|
168
|
+
});
|
|
169
|
+
s = emphasize(s).replace(
|
|
170
|
+
/\0L(\d+)\0/g,
|
|
171
|
+
(_all, i) => {
|
|
172
|
+
const link = links[Number(i)];
|
|
173
|
+
return `<a href="${link.url}" target="_blank" rel="noopener noreferrer">${emphasize(link.text)}</a>`;
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
return s.replace(/\0(\d+)\0/g, (_all, i) => `<code>${spans[Number(i)]}</code>`);
|
|
177
|
+
}
|
|
178
|
+
var CLOSING_FENCE = /^ {0,3}(?:`{3,}|~{3,})\s*$/;
|
|
179
|
+
function renderFence(raw) {
|
|
180
|
+
const lines = raw.split("\n").slice(1);
|
|
181
|
+
if (lines.length && CLOSING_FENCE.test(lines[lines.length - 1])) lines.pop();
|
|
182
|
+
return `<pre><code>${escapeHtml(lines.join("\n"))}</code></pre>`;
|
|
183
|
+
}
|
|
184
|
+
function renderIndentedCode(raw) {
|
|
185
|
+
const body = raw.split("\n").map((l) => l.replace(/^(?: {4}|\t)/, "")).join("\n");
|
|
186
|
+
return `<pre><code>${escapeHtml(body)}</code></pre>`;
|
|
187
|
+
}
|
|
188
|
+
var DELIMITER_CELL = /^:?-+:?$/;
|
|
189
|
+
function cellsOf(line) {
|
|
190
|
+
const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
191
|
+
return trimmed.split(/(?<!\\)\|/).map((c) => c.trim().replace(/\\\|/g, "|"));
|
|
192
|
+
}
|
|
193
|
+
var alignOf = (cell) => {
|
|
194
|
+
const left = cell.startsWith(":");
|
|
195
|
+
const right = cell.endsWith(":");
|
|
196
|
+
return left && right ? "center" : right ? "right" : left ? "left" : null;
|
|
197
|
+
};
|
|
198
|
+
function renderTable(lines) {
|
|
199
|
+
if (lines.length < 2 || !lines[0].includes("|")) return null;
|
|
200
|
+
const delimiter = cellsOf(lines[1]);
|
|
201
|
+
if (!delimiter.length || !delimiter.every((c) => DELIMITER_CELL.test(c))) return null;
|
|
202
|
+
const head = cellsOf(lines[0]);
|
|
203
|
+
if (head.length !== delimiter.length) return null;
|
|
204
|
+
const align = delimiter.map(alignOf);
|
|
205
|
+
const cell = (tag, text, i) => {
|
|
206
|
+
const a = align[i];
|
|
207
|
+
return `<${tag}${a ? ` class="sc-md-${a}"` : ""}>${inline(text)}</${tag}>`;
|
|
208
|
+
};
|
|
209
|
+
const body = lines.slice(2).filter((l) => l.trim() !== "").map((l) => {
|
|
210
|
+
const row = cellsOf(l);
|
|
211
|
+
const cells = Array.from({ length: head.length }, (_, i) => cell("td", row[i] ?? "", i));
|
|
212
|
+
return `<tr>${cells.join("")}</tr>`;
|
|
213
|
+
}).join("");
|
|
214
|
+
return `<table class="sc-md-table"><thead><tr>${head.map((h, i) => cell("th", h, i)).join("")}</tr></thead><tbody>${body}</tbody></table>`;
|
|
215
|
+
}
|
|
216
|
+
var LIST_ITEM = /^(\s*)([-*+]|\d{1,9}[.)])[ \t]+(.*)$/;
|
|
217
|
+
function parseList(lines) {
|
|
218
|
+
const first = LIST_ITEM.exec(lines[0] ?? "");
|
|
219
|
+
if (!first) return null;
|
|
220
|
+
const base = first[1].length;
|
|
221
|
+
const marker = first[2];
|
|
222
|
+
const ordered = /^\d/.test(marker);
|
|
223
|
+
const strip = new RegExp(`^ {0,${base + marker.length + 1}}`);
|
|
224
|
+
const items = [];
|
|
225
|
+
for (const line of lines) {
|
|
226
|
+
const m = LIST_ITEM.exec(line);
|
|
227
|
+
if (m && m[1].length <= base) {
|
|
228
|
+
items.push([m[3]]);
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (!items.length) return null;
|
|
232
|
+
items[items.length - 1].push(line.replace(strip, ""));
|
|
233
|
+
}
|
|
234
|
+
return { ordered, start: ordered ? Number.parseInt(marker, 10) : 1, items: items.map((l) => l.join("\n")) };
|
|
235
|
+
}
|
|
236
|
+
function renderItem(item, depth) {
|
|
237
|
+
const lines = item.replace(/\s+$/, "").split("\n");
|
|
238
|
+
const nestedAt = lines.findIndex((l, i) => i > 0 && LIST_ITEM.test(l));
|
|
239
|
+
const head = (nestedAt === -1 ? lines : lines.slice(0, nestedAt)).filter((l) => l.trim() !== "");
|
|
240
|
+
const rest = nestedAt === -1 ? [] : lines.slice(nestedAt);
|
|
241
|
+
const loose = /\n[ \t]*\n/.test(item.trim());
|
|
242
|
+
const headHtml = head.length ? loose ? renderSource(head.join("\n"), depth + 1) : inline(head.join(" ").trim()) : "";
|
|
243
|
+
return headHtml + (rest.length ? renderSource(rest.join("\n"), depth + 1) : "");
|
|
244
|
+
}
|
|
245
|
+
function renderList(lines, depth) {
|
|
246
|
+
const parsed = parseList(lines);
|
|
247
|
+
if (!parsed) return null;
|
|
248
|
+
const items = parsed.items.map((item) => `<li>${renderItem(item, depth)}</li>`).join("");
|
|
249
|
+
if (!parsed.ordered) return `<ul>${items}</ul>`;
|
|
250
|
+
return `<ol${parsed.start !== 1 ? ` start="${parsed.start}"` : ""}>${items}</ol>`;
|
|
251
|
+
}
|
|
252
|
+
var QUOTE_MARK = /^ {0,3}> ?/;
|
|
253
|
+
var THEMATIC_BREAK = /^ {0,3}(?:-{3,}|\*{3,}|_{3,})\s*$/;
|
|
254
|
+
var SETEXT = /^ {0,3}(=+|-+)\s*$/;
|
|
255
|
+
var ATX = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/;
|
|
256
|
+
function renderProse(lines) {
|
|
257
|
+
const out = [];
|
|
258
|
+
let para = [];
|
|
259
|
+
const flush = () => {
|
|
260
|
+
if (!para.length) return;
|
|
261
|
+
out.push(`<p>${para.map(inline).join("<br/>")}</p>`);
|
|
262
|
+
para = [];
|
|
263
|
+
};
|
|
264
|
+
for (const line of lines) {
|
|
265
|
+
const h = ATX.exec(line);
|
|
266
|
+
if (h) {
|
|
267
|
+
flush();
|
|
268
|
+
const level = Math.min(h[1].length + 1, 6);
|
|
269
|
+
out.push(`<h${level}>${inline(h[2])}</h${level}>`);
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
para.push(line);
|
|
273
|
+
}
|
|
274
|
+
flush();
|
|
275
|
+
return out.join("");
|
|
276
|
+
}
|
|
277
|
+
function renderTextBlock(raw, depth) {
|
|
278
|
+
if (isPlainProse(raw)) {
|
|
279
|
+
return `<p>${escapeHtml(raw).replace(/\n/g, "<br/>")}</p>`;
|
|
280
|
+
}
|
|
281
|
+
const lines = raw.split("\n");
|
|
282
|
+
const table = renderTable(lines);
|
|
283
|
+
if (table) return table;
|
|
284
|
+
if (depth < MAX_DEPTH && QUOTE_MARK.test(lines[0])) {
|
|
285
|
+
const inner = lines.map((l) => l.replace(QUOTE_MARK, "")).join("\n");
|
|
286
|
+
return `<blockquote>${renderSource(inner, depth + 1)}</blockquote>`;
|
|
287
|
+
}
|
|
288
|
+
if (depth < MAX_DEPTH) {
|
|
289
|
+
const list = renderList(lines, depth);
|
|
290
|
+
if (list) return list;
|
|
291
|
+
}
|
|
292
|
+
if (lines.length === 1 && THEMATIC_BREAK.test(lines[0])) return "<hr/>";
|
|
293
|
+
const last = lines[lines.length - 1];
|
|
294
|
+
if (lines.length >= 2 && SETEXT.test(last)) {
|
|
295
|
+
const level = last.trim().startsWith("=") ? 2 : 3;
|
|
296
|
+
const text = lines.slice(0, -1).join(" ").trim();
|
|
297
|
+
return `<h${level}>${inline(text)}</h${level}>`;
|
|
298
|
+
}
|
|
299
|
+
return renderProse(lines);
|
|
300
|
+
}
|
|
301
|
+
function renderBlock(src, block, depth) {
|
|
302
|
+
const raw = src.slice(block.start, block.end);
|
|
303
|
+
if (block.kind === "fence") return renderFence(raw);
|
|
304
|
+
if (block.kind === "code") return renderIndentedCode(raw);
|
|
305
|
+
return renderTextBlock(raw, depth);
|
|
306
|
+
}
|
|
307
|
+
function renderSource(src, depth) {
|
|
308
|
+
return splitBlocks(src).map((b) => renderBlock(src, b, depth)).join("");
|
|
309
|
+
}
|
|
310
|
+
function renderMarkdown(src) {
|
|
311
|
+
return renderSource(src, 0);
|
|
312
|
+
}
|
|
313
|
+
var newMarkdownStream = () => ({ settled: "", html: "", resume: 0 });
|
|
314
|
+
function renderMarkdownStream(src, stream) {
|
|
315
|
+
if (!src.startsWith(stream.settled)) Object.assign(stream, newMarkdownStream());
|
|
316
|
+
const from = stream.resume;
|
|
317
|
+
const tail = src.slice(from);
|
|
318
|
+
const blocks = splitBlocks(tail);
|
|
319
|
+
const lastLine = src.lastIndexOf("\n") + 1 - from;
|
|
320
|
+
let html = stream.html;
|
|
321
|
+
for (let i = 0; i < blocks.length; i += 1) {
|
|
322
|
+
const rendered = renderBlock(tail, blocks[i], 0);
|
|
323
|
+
html += rendered;
|
|
324
|
+
if (i + 1 < blocks.length && blocks[i + 1].start < lastLine) {
|
|
325
|
+
stream.html += rendered;
|
|
326
|
+
stream.resume = from + blocks[i].end + 1;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
stream.settled = src.slice(0, lastLine + from);
|
|
330
|
+
return html;
|
|
331
|
+
}
|
|
332
|
+
function renderMarkdownWithAnchors(src) {
|
|
333
|
+
const blocks = splitBlocks(src);
|
|
334
|
+
const html = blocks.map((block, i) => {
|
|
335
|
+
const rendered = renderBlock(src, block, 0);
|
|
336
|
+
return rendered.replace(/^(\s*<[a-z][a-z0-9]*)/i, `$1 data-sc-block="${i}"`);
|
|
337
|
+
}).join("");
|
|
338
|
+
return { html, blocks };
|
|
339
|
+
}
|
|
340
|
+
export {
|
|
341
|
+
deltaTone,
|
|
342
|
+
downloadThread,
|
|
343
|
+
formatDelta,
|
|
344
|
+
formatValue,
|
|
345
|
+
newMarkdownStream,
|
|
346
|
+
renderMarkdown,
|
|
347
|
+
renderMarkdownStream,
|
|
348
|
+
renderMarkdownWithAnchors,
|
|
349
|
+
safeHref,
|
|
350
|
+
threadToMarkdown,
|
|
351
|
+
toneClass
|
|
352
|
+
};
|
|
353
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/format.ts","../src/export.ts","../src/markdown.ts"],"sourcesContent":["// Value formatting shared by every card renderer.\n//\n// Centralised because a table cell and a stat tile showing the same number in\n// different formats is the fastest way to make an interface look untrustworthy.\n\nimport type { CardValueFormat } from \"@supersolutions/super-chat-core\";\n\nconst compact = new Intl.NumberFormat(undefined, { notation: \"compact\", maximumFractionDigits: 2 });\nconst plain = new Intl.NumberFormat(undefined, { maximumFractionDigits: 6 });\nconst pctWide = new Intl.NumberFormat(undefined, { maximumFractionDigits: 1, useGrouping: false });\nconst pctNarrow = new Intl.NumberFormat(undefined, { maximumFractionDigits: 2, useGrouping: false });\nconst percent = (n: number): string => (Math.abs(n) < 1 ? pctNarrow : pctWide).format(n);\n\nexport function formatValue(value: unknown, format: CardValueFormat = \"text\"): string {\n if (value == null) return \"—\";\n\n switch (format) {\n case \"number\": {\n const n = Number(value);\n if (!Number.isFinite(n)) return String(value);\n // Compact only above 5 digits: \"12.3K\" is helpful, \"1.2K\" hides precision\n // people expect to see on small counts.\n return Math.abs(n) >= 100_000 ? compact.format(n) : plain.format(n);\n }\n case \"currency\": {\n const n = Number(value);\n if (!Number.isFinite(n)) return String(value);\n const abs = Math.abs(n);\n // Sub-cent values are common in crypto; fixed 2dp would render them as $0.00.\n const digits = abs >= 1 ? 2 : abs >= 0.01 ? 4 : 8;\n // A whole amount in the thousands reads as \"$48,200\". Forcing \".00\" onto\n // it is the machine-printed look; amounts with cents keep them.\n const min = abs >= 1000 && Number.isInteger(n) ? 0 : 2;\n return `$${n.toLocaleString(undefined, { minimumFractionDigits: min, maximumFractionDigits: Math.max(min, digits) })}`;\n }\n case \"percent\": {\n const n = Number(value);\n if (!Number.isFinite(n)) return String(value);\n // One decimal at most (\"8.2%\", \"12%\"), two only below 1% where the\n // second digit is the signal (\"0.04%\"). A fixed \"8.20%\" is false precision.\n return `${percent(n)}%`;\n }\n case \"bytes\": {\n const n = Number(value);\n if (!Number.isFinite(n)) return String(value);\n const units = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\"];\n let i = 0;\n let v = n;\n while (v >= 1024 && i < units.length - 1) {\n v /= 1024;\n i += 1;\n }\n return `${v.toFixed(i === 0 ? 0 : 1)} ${units[i]}`;\n }\n case \"duration\": {\n const ms = Number(value);\n if (!Number.isFinite(ms)) return String(value);\n if (ms < 1000) return `${Math.round(ms)}ms`;\n if (ms < 60_000) return `${(ms / 1000).toFixed(1)}s`;\n if (ms < 3_600_000) return `${Math.floor(ms / 60_000)}m ${Math.round((ms % 60_000) / 1000)}s`;\n return `${(ms / 3_600_000).toFixed(1)}h`;\n }\n case \"datetime\": {\n const d = typeof value === \"number\" ? new Date(value) : new Date(String(value));\n return Number.isNaN(d.getTime()) ? String(value) : d.toLocaleString();\n }\n case \"code\":\n case \"text\":\n default:\n return typeof value === \"object\" ? JSON.stringify(value) : String(value);\n }\n}\n\nexport function formatDelta(delta: number, format: CardValueFormat = \"number\"): string {\n // A true minus sign: the hyphen-minus is narrower and misaligns a column of\n // signed deltas against the plus signs above it.\n const sign = delta > 0 ? \"+\" : delta < 0 ? \"−\" : \"\";\n return `${sign}${formatValue(Math.abs(delta), format)}`;\n}\n\nexport const toneClass = (tone?: string): string => (tone && tone !== \"neutral\" ? ` sc-tone--${tone}` : \"\");\n\n/** Positive is not always good — but for a delta with no stated tone it is the useful default. */\nexport const deltaTone = (delta: number): \"positive\" | \"negative\" | \"neutral\" =>\n delta > 0 ? \"positive\" : delta < 0 ? \"negative\" : \"neutral\";\n\n/**\n * A URL that came from a model or a tool, made safe to put in an `href`: only http(s) links\n * pass, anything else (`javascript:`, `data:`, `vbscript:`, a relative path that could be read\n * as a scheme after whitespace tricks) comes back as `undefined` and the caller renders plain\n * text. React 19 refuses `javascript:` hrefs itself, but this package supports React 18, which\n * only warns and then navigates.\n */\nexport function safeHref(url: string | undefined | null): string | undefined {\n if (typeof url !== \"string\") return undefined;\n const trimmed = url.trim();\n // Browsers strip tab and newline characters inside a URL before parsing it, so\n // `java\\tscript:` is a javascript: URL; reject anything with control characters outright.\n // eslint-disable-next-line no-control-regex\n if (/[\\u0000-\\u001f\\u007f]/.test(trimmed)) return undefined;\n return /^https?:\\/\\/[^\\s]+$/i.test(trimmed) ? trimmed : undefined;\n}\n","// Thread export.\n//\n// Markdown rather than JSON: the point of exporting a conversation is to read it\n// somewhere else or paste it into a ticket, and JSON serves neither. Cards are\n// rendered as their data, not as their markup — a table exported as HTML is\n// useless in a text file, but as a markdown table it survives.\n//\n// Sharing (a hosted link) is deliberately NOT here: it needs a backend the kit\n// does not have, and faking it with a data: URL would produce links that break\n// the moment they leave the browser.\n\nimport type { Card, ContentPart, Message } from \"@supersolutions/super-chat-core\";\n\nfunction cardToMarkdown(spec: Record<string, unknown>): string {\n const kind = String(spec.kind ?? \"unknown\");\n const title = spec.title ? `**${spec.title}**\\n\\n` : \"\";\n\n if (kind === \"table\" && Array.isArray(spec.columns) && Array.isArray(spec.rows)) {\n const cols = spec.columns as { key: string; label: string }[];\n const rows = spec.rows as Record<string, unknown>[];\n const head = `| ${cols.map((c) => c.label).join(\" | \")} |`;\n const rule = `| ${cols.map(() => \"---\").join(\" | \")} |`;\n const body = rows.map((r) => `| ${cols.map((c) => String(r[c.key] ?? \"\")).join(\" | \")} |`).join(\"\\n\");\n return `${title}${head}\\n${rule}\\n${body}`;\n }\n\n if (kind === \"markdown\" && typeof spec.body === \"string\") return `${title}${spec.body}`;\n if (kind === \"code\" && typeof spec.code === \"string\") {\n return `${title}\\`\\`\\`${spec.language ?? \"\"}\\n${spec.code}\\n\\`\\`\\``;\n }\n if (kind === \"callout\" && typeof spec.body === \"string\") return `> ${title}${spec.body}`;\n\n // Everything else keeps its data rather than being dropped — an export that\n // silently omits a card is worse than one that is a little verbose.\n return `${title}\\`\\`\\`json\\n${JSON.stringify(spec, null, 2)}\\n\\`\\`\\``;\n}\n\nfunction partToMarkdown(part: ContentPart): string | null {\n switch (part.type) {\n case \"text\":\n return part.text;\n case \"reasoning\":\n return `<details><summary>Reasoning</summary>\\n\\n${part.text}\\n\\n</details>`;\n case \"tool-call\":\n return `- \\`${part.name}(${JSON.stringify(part.input ?? {})})\\``;\n case \"tool-result\":\n return part.failure ? `- \\`${part.name}\\` failed: ${part.failure}` : null;\n case \"image\":\n return \"_(image)_\";\n case \"file\":\n return `_(file: ${part.filename ?? \"attachment\"})_`;\n case \"artifact\":\n return part.kind.startsWith(\"card:\")\n ? cardToMarkdown(((part.data as { spec?: Card[\"spec\"] }).spec ?? part.data) as Record<string, unknown>)\n : null;\n default:\n return null;\n }\n}\n\n/** Render a thread as markdown. `title` becomes the H1 when given. */\nexport function threadToMarkdown(messages: readonly Message[], title?: string): string {\n const out: string[] = title ? [`# ${title}`, \"\"] : [];\n\n for (const m of messages) {\n if (m.role === \"system\") continue;\n const body = m.parts.map(partToMarkdown).filter(Boolean).join(\"\\n\\n\");\n if (!body) continue;\n const who = m.role === \"user\" ? \"You\" : m.role === \"tool\" ? \"Tools\" : \"Assistant\";\n const when = m.createdAt ? ` · ${new Date(m.createdAt).toISOString().slice(0, 16).replace(\"T\", \" \")}` : \"\";\n out.push(`## ${who}${when}`, \"\", body, \"\");\n }\n\n return out.join(\"\\n\").trimEnd() + \"\\n\";\n}\n\n/** Trigger a download of the thread as a `.md` file. */\nexport function downloadThread(messages: readonly Message[], filename = \"conversation.md\", title?: string): void {\n const blob = new Blob([threadToMarkdown(messages, title)], { type: \"text/markdown;charset=utf-8\" });\n const url = URL.createObjectURL(blob);\n const a = document.createElement(\"a\");\n a.href = url;\n a.download = filename;\n a.click();\n // Revoking immediately can race the download in some browsers; one frame is\n // enough for the click to have been consumed.\n requestAnimationFrame(() => URL.revokeObjectURL(url));\n}\n","// Minimal markdown renderer for assistant text, markdown cards and document\n// artifacts.\n//\n// Deliberately not a full parser — a chat message or card body is short, and\n// pulling in a markdown library plus a sanitizer for this is disproportionate.\n//\n// It does now split into blocks before rendering, and that is not a stylistic\n// change. A document previewer has to answer \"the user selected this on screen;\n// where is it in the source?\", because that span is both what gets quoted into\n// the next request and what an edit has to anchor against. The previous shape —\n// escape the whole string, pull fences out into placeholders, then run a chain\n// of global regexes — destroyed source positions in its first statement.\n//\n// So the order is inverted: split on the RAW source and record offsets, then\n// escape and transform each block independently. Escaping per block rather than\n// up front is load-bearing, not tidiness: `&` → `&` changes the string\n// length, so escaping first would shift every offset recorded afterwards. That\n// failure is invisible on screen — the page renders perfectly and the anchors\n// silently point at the wrong text — which is why markdown.test.ts asserts the\n// offsets round-trip rather than trusting the output to look right.\n//\n// ── Why it grew ──────────────────────────────────────────────────────────────\n//\n// The block set used to be headings, emphasis, code, links and bullet lists,\n// and for a chat bubble that is the right amount of renderer. A document\n// artifact changed the requirement under it: a document is a thing the user\n// KEEPS, reads in a previewer and downloads as `.md`, and a report whose table\n// renders as a column of literal pipes is not a document — it is the source of\n// one. Tables, quotes, ordered lists and indented code are not exotic; they are\n// what anyone writing a report reaches for in the first paragraph.\n//\n// The structure changed with the scope. A chain of global regexes over one\n// escaped string cannot tell a table from a paragraph, so each block is now\n// CLASSIFIED first and rendered by shape, and only the leaves run inline\n// transforms. Nesting (a list inside a quote, a quote inside a list) falls out\n// of rendering a block's interior through the same splitter, with a depth cap\n// so a pathological `> > > > …` cannot recurse without end.\n\nimport { splitBlocks, type MarkdownBlock } from \"@supersolutions/super-chat-core\";\n\nexport type AnchoredMarkdown = {\n html: string;\n /** Index-aligned with the `data-sc-block` attribute on the rendered HTML. */\n blocks: MarkdownBlock[];\n};\n\n// Cheap pre-check carried over from main: with none of these characters\n// present, no heading, emphasis, code, link, list, quote or table rule below\n// could match, so the whole chain is skippable. Applied per BLOCK rather than\n// per document — one fenced snippet in an otherwise plain artifact should not\n// cost the other forty paragraphs their shortcut.\nconst MARKDOWN_SIGNIFICANT = /[`*_#[\\]>~|-]/;\n// Two constructs carry no character the test above would catch: an ordered\n// item, and a setext heading underlined with `=`. Adding `=` and the digits to\n// MARKDOWN_SIGNIFICANT would cost the shortcut on most prose, so they get their\n// own (equally cheap) look instead.\nconst ORDERED_ITEM = /^ {0,3}\\d{1,9}[.)]\\s/m;\nconst SETEXT_EQUALS = /\\n {0,3}=+[ \\t]*$/;\n\nconst isPlainProse = (raw: string) =>\n !MARKDOWN_SIGNIFICANT.test(raw) && !ORDERED_ITEM.test(raw) && !SETEXT_EQUALS.test(raw);\n\n/** How deep a quote or list may nest before its interior is rendered flat. */\nconst MAX_DEPTH = 4;\n\n// Quotes are escaped because link URLs are interpolated into href=\"…\" — an\n// unescaped quote in a URL would close the attribute and open a new one\n// (browsers recover from the missing-whitespace parse error by reading\n// `\"onmouseover=\"…` as a fresh attribute).\n//\n// NUL is dropped here, at the one place every leaf is escaped, rather than only in\n// `inline`: the inline placeholders below are built from it, so it must never come from\n// the source, and code blocks and the plain-prose shortcut would otherwise let a raw\n// U+0000 through into the output. (Block offsets are computed on the raw source, so\n// removing it from the output moves no anchor.)\nconst escapeHtml = (s: string) =>\n s.replace(/\\0/g, \"\").replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\").replace(/\"/g, \""\");\n\n// ── Inline ───────────────────────────────────────────────────────────────────\n\n/**\n * Escape, then transform. Every leaf goes through here and nothing else does.\n *\n * Code spans are lifted out FIRST and put back last, so `**not bold**` inside\n * backticks stays literal — the same protection fenced blocks get, which the\n * old chain gave only to fences. NUL is stripped from the input because the\n * placeholders are built from it; without that, text could forge one.\n */\n// Only http(s) links — a javascript: URL must never survive. The destination may\n// contain one level of balanced parentheses (`…/wiki/Foo_(bar)`), as CommonMark\n// allows; the two alternatives cannot match the same character, so there is no\n// backtracking blow-up on a hostile string.\nconst LINK = /\\[([^\\]]+)\\]\\((https?:\\/\\/(?:[^()\\s]|\\([^()\\s]*\\))+)\\)/g;\n\n/** Strike-through, strong, emphasis. Runs on already-escaped text. */\nconst emphasize = (s: string) =>\n s\n .replace(/~~([^~\\n]+)~~/g, \"<del>$1</del>\")\n .replace(/\\*\\*([^*]+)\\*\\*/g, \"<strong>$1</strong>\")\n .replace(/(^|[^*])\\*([^*\\n]+)\\*/g, \"$1<em>$2</em>\");\n\nfunction inline(raw: string): string {\n const spans: string[] = [];\n const spanSource: string[] = []; // what each code span looked like, for where it must stay literal\n let s = escapeHtml(raw);\n\n s = s.replace(/(`+)([\\s\\S]+?)\\1(?!`)/g, (all, _ticks, body: string) => {\n spans.push(body);\n spanSource.push(all);\n return `\\0${spans.length - 1}\\0`;\n });\n\n // Links are lifted out the same way, BEFORE emphasis. Otherwise the emphasis rules\n // run over the destination too, and `…/a*b*c` becomes `href=\"…/a<em>b</em>c\"`: the\n // link silently points somewhere else. Only the link's text is emphasised.\n const links: { text: string; url: string }[] = [];\n s = s.replace(LINK, (_all, text: string, url: string) => {\n // A backtick pair inside a URL is part of the URL, not a code span.\n const literal = url.replace(/\\0(\\d+)\\0/g, (_m, i: string) => spanSource[Number(i)]!);\n links.push({ text, url: literal });\n return `\\0L${links.length - 1}\\0`;\n });\n\n s = emphasize(s).replace(\n /\\0L(\\d+)\\0/g,\n (_all, i: string) => {\n const link = links[Number(i)]!;\n return `<a href=\"${link.url}\" target=\"_blank\" rel=\"noopener noreferrer\">${emphasize(link.text)}</a>`;\n },\n );\n\n return s.replace(/\\0(\\d+)\\0/g, (_all, i: string) => `<code>${spans[Number(i)]}</code>`);\n}\n\n// ── Verbatim blocks ──────────────────────────────────────────────────────────\n\nconst CLOSING_FENCE = /^ {0,3}(?:`{3,}|~{3,})\\s*$/;\n\nfunction renderFence(raw: string): string {\n // Drop the opening fence line (which may carry a language) and the closing\n // one if it is there — an unterminated fence has none. Content is escaped but\n // never sees an inline transform.\n const lines = raw.split(\"\\n\").slice(1);\n if (lines.length && CLOSING_FENCE.test(lines[lines.length - 1]!)) lines.pop();\n return `<pre><code>${escapeHtml(lines.join(\"\\n\"))}</code></pre>`;\n}\n\nfunction renderIndentedCode(raw: string): string {\n const body = raw.split(\"\\n\").map((l) => l.replace(/^(?: {4}|\\t)/, \"\")).join(\"\\n\");\n return `<pre><code>${escapeHtml(body)}</code></pre>`;\n}\n\n// ── Tables ───────────────────────────────────────────────────────────────────\n\ntype Align = \"left\" | \"center\" | \"right\" | null;\n\nconst DELIMITER_CELL = /^:?-+:?$/;\n\n/** Split a pipe row into cells, honouring `\\|` as a literal pipe. */\nfunction cellsOf(line: string): string[] {\n const trimmed = line.trim().replace(/^\\|/, \"\").replace(/\\|$/, \"\");\n return trimmed\n .split(/(?<!\\\\)\\|/)\n .map((c) => c.trim().replace(/\\\\\\|/g, \"|\"));\n}\n\nconst alignOf = (cell: string): Align => {\n const left = cell.startsWith(\":\");\n const right = cell.endsWith(\":\");\n return left && right ? \"center\" : right ? \"right\" : left ? \"left\" : null;\n};\n\nfunction renderTable(lines: string[]): string | null {\n if (lines.length < 2 || !lines[0]!.includes(\"|\")) return null;\n const delimiter = cellsOf(lines[1]!);\n if (!delimiter.length || !delimiter.every((c) => DELIMITER_CELL.test(c))) return null;\n\n const head = cellsOf(lines[0]!);\n if (head.length !== delimiter.length) return null;\n const align = delimiter.map(alignOf);\n\n // Alignment rides on a class rather than a style attribute: a host with a\n // strict CSP can ship this without allowing inline styles.\n const cell = (tag: \"th\" | \"td\", text: string, i: number) => {\n const a = align[i];\n return `<${tag}${a ? ` class=\"sc-md-${a}\"` : \"\"}>${inline(text)}</${tag}>`;\n };\n\n const body = lines\n .slice(2)\n .filter((l) => l.trim() !== \"\")\n .map((l) => {\n const row = cellsOf(l);\n // Short rows are padded and long ones cut, so a ragged table still lines\n // up under its header instead of leaking cells into a new column.\n const cells = Array.from({ length: head.length }, (_, i) => cell(\"td\", row[i] ?? \"\", i));\n return `<tr>${cells.join(\"\")}</tr>`;\n })\n .join(\"\");\n\n return `<table class=\"sc-md-table\"><thead><tr>${head\n .map((h, i) => cell(\"th\", h, i))\n .join(\"\")}</tr></thead><tbody>${body}</tbody></table>`;\n}\n\n// ── Lists ────────────────────────────────────────────────────────────────────\n\nconst LIST_ITEM = /^(\\s*)([-*+]|\\d{1,9}[.)])[ \\t]+(.*)$/;\n\ntype ParsedList = { ordered: boolean; start: number; items: string[] };\n\nfunction parseList(lines: string[]): ParsedList | null {\n const first = LIST_ITEM.exec(lines[0] ?? \"\");\n if (!first) return null;\n const base = first[1]!.length;\n const marker = first[2]!;\n const ordered = /^\\d/.test(marker);\n // Everything indented at least as far as the first item's text belongs to\n // that item — its wrapped lines, its paragraphs, and any list nested under it.\n const strip = new RegExp(`^ {0,${base + marker.length + 1}}`);\n\n const items: string[][] = [];\n for (const line of lines) {\n const m = LIST_ITEM.exec(line);\n if (m && m[1]!.length <= base) {\n items.push([m[3]!]);\n continue;\n }\n if (!items.length) return null;\n items[items.length - 1]!.push(line.replace(strip, \"\"));\n }\n\n return { ordered, start: ordered ? Number.parseInt(marker, 10) : 1, items: items.map((l) => l.join(\"\\n\")) };\n}\n\n/**\n * One item's interior.\n *\n * A single-paragraph item stays tight — `<li>text</li>`, not\n * `<li><p>text</p></li>` — because the paragraph margin inside a list item is\n * the classic \"why is my list double-spaced\" bug. Anything with a blank line or\n * a nested list goes back through the block pipeline, which is where nesting\n * comes from.\n */\nfunction renderItem(item: string, depth: number): string {\n const lines = item.replace(/\\s+$/, \"\").split(\"\\n\");\n const nestedAt = lines.findIndex((l, i) => i > 0 && LIST_ITEM.test(l));\n const head = (nestedAt === -1 ? lines : lines.slice(0, nestedAt)).filter((l) => l.trim() !== \"\");\n const rest = nestedAt === -1 ? [] : lines.slice(nestedAt);\n const loose = /\\n[ \\t]*\\n/.test(item.trim());\n\n const headHtml = head.length\n ? loose\n ? renderSource(head.join(\"\\n\"), depth + 1)\n : inline(head.join(\" \").trim())\n : \"\";\n return headHtml + (rest.length ? renderSource(rest.join(\"\\n\"), depth + 1) : \"\");\n}\n\nfunction renderList(lines: string[], depth: number): string | null {\n const parsed = parseList(lines);\n if (!parsed) return null;\n const items = parsed.items.map((item) => `<li>${renderItem(item, depth)}</li>`).join(\"\");\n if (!parsed.ordered) return `<ul>${items}</ul>`;\n return `<ol${parsed.start !== 1 ? ` start=\"${parsed.start}\"` : \"\"}>${items}</ol>`;\n}\n\n// ── Prose ────────────────────────────────────────────────────────────────────\n\nconst QUOTE_MARK = /^ {0,3}> ?/;\nconst THEMATIC_BREAK = /^ {0,3}(?:-{3,}|\\*{3,}|_{3,})\\s*$/;\nconst SETEXT = /^ {0,3}(=+|-+)\\s*$/;\n// Headings shift down one: the card or page owns the h1, so a document's own\n// `#` must not compete with it for the document outline a screen reader builds.\nconst ATX = /^ {0,3}(#{1,6})\\s+(.*?)\\s*#*\\s*$/;\n\nfunction renderProse(lines: string[]): string {\n const out: string[] = [];\n let para: string[] = [];\n const flush = () => {\n if (!para.length) return;\n out.push(`<p>${para.map(inline).join(\"<br/>\")}</p>`);\n para = [];\n };\n\n for (const line of lines) {\n const h = ATX.exec(line);\n if (h) {\n flush();\n const level = Math.min(h[1]!.length + 1, 6);\n out.push(`<h${level}>${inline(h[2]!)}</h${level}>`);\n continue;\n }\n para.push(line);\n }\n flush();\n return out.join(\"\");\n}\n\nfunction renderTextBlock(raw: string, depth: number): string {\n if (isPlainProse(raw)) {\n // Escaping still happens — safety is not what the shortcut skips.\n return `<p>${escapeHtml(raw).replace(/\\n/g, \"<br/>\")}</p>`;\n }\n\n const lines = raw.split(\"\\n\");\n\n const table = renderTable(lines);\n if (table) return table;\n\n if (depth < MAX_DEPTH && QUOTE_MARK.test(lines[0]!)) {\n const inner = lines.map((l) => l.replace(QUOTE_MARK, \"\")).join(\"\\n\");\n return `<blockquote>${renderSource(inner, depth + 1)}</blockquote>`;\n }\n\n if (depth < MAX_DEPTH) {\n const list = renderList(lines, depth);\n if (list) return list;\n }\n\n if (lines.length === 1 && THEMATIC_BREAK.test(lines[0]!)) return \"<hr/>\";\n\n // Setext: the underline belongs to the lines above it, and reading it as a\n // paragraph followed by a rule is the wrong document — the title stops being\n // a heading, which is exactly what the outline is built from.\n const last = lines[lines.length - 1]!;\n if (lines.length >= 2 && SETEXT.test(last)) {\n const level = last.trim().startsWith(\"=\") ? 2 : 3;\n const text = lines.slice(0, -1).join(\" \").trim();\n return `<h${level}>${inline(text)}</h${level}>`;\n }\n\n return renderProse(lines);\n}\n\n// ── Assembly ─────────────────────────────────────────────────────────────────\n\nfunction renderBlock(src: string, block: MarkdownBlock, depth: number): string {\n const raw = src.slice(block.start, block.end);\n if (block.kind === \"fence\") return renderFence(raw);\n if (block.kind === \"code\") return renderIndentedCode(raw);\n return renderTextBlock(raw, depth);\n}\n\n/** Split and render a source, with no anchors. Also the recursion step. */\nfunction renderSource(src: string, depth: number): string {\n return splitBlocks(src)\n .map((b) => renderBlock(src, b, depth))\n .join(\"\");\n}\n\n/** Render for the transcript: no anchors, because chat prose is not addressed. */\nexport function renderMarkdown(src: string): string {\n return renderSource(src, 0);\n}\n\n/** What renderMarkdownStream keeps between calls. Start from newMarkdownStream(). */\nexport type MarkdownStream = {\n /** The source the cached blocks were decided on; valid while the text starts with it. */\n settled: string;\n /** Rendered HTML of those blocks. */\n html: string;\n /** Where the block after them starts looking: the line after the last one. */\n resume: number;\n};\n\nexport const newMarkdownStream = (): MarkdownStream => ({ settled: \"\", html: \"\", resume: 0 });\n\n/**\n * renderMarkdown for text that grows while it is shown — always the same\n * string renderMarkdown(src) returns, but blocks that can no longer change are\n * rendered once and reused, so a streamed answer costs its open tail per\n * frame instead of its whole length.\n *\n * Every block renders from its own source slice alone, so the only question\n * is which blocks later text can still move. splitBlocks decides a block's\n * extent from its own lines and, at most, the first line of the block after\n * it: the blank line or fence opener that ends it, and for a list or quote the\n * next non-blank line, which may continue it. Whether a line is blank, a fence\n * opener or closer, a list item or a quote can change while it is the last,\n * unterminated line — `1` becomes `1.`, a closing ``` becomes ```js, ``` gains\n * a backtick and stops opening a fence, a blank line gets text. Every line\n * before the last is final. So a block is settled once the block after it\n * starts before the last line: a setext underline, a loose list's next item,\n * a table's delimiter row or the rest of an open fence all belong to the\n * block that is still open. (This renderer has no reference definitions,\n * footnotes or raw HTML blocks, the other constructs that reach back.) And\n * splitBlocks never looks behind the line it stands on, so splitting from the\n * line after the settled blocks yields the same blocks the whole text would.\n *\n * Text that does not start with `stream.settled` — a new run, an edit — drops\n * the cache and renders from scratch.\n */\nexport function renderMarkdownStream(src: string, stream: MarkdownStream): string {\n if (!src.startsWith(stream.settled)) Object.assign(stream, newMarkdownStream());\n\n const from = stream.resume;\n const tail = src.slice(from);\n const blocks = splitBlocks(tail);\n const lastLine = src.lastIndexOf(\"\\n\") + 1 - from;\n let html = stream.html;\n for (let i = 0; i < blocks.length; i += 1) {\n const rendered = renderBlock(tail, blocks[i]!, 0);\n html += rendered;\n if (i + 1 < blocks.length && blocks[i + 1]!.start < lastLine) {\n stream.html += rendered;\n stream.resume = from + blocks[i]!.end + 1;\n }\n }\n stream.settled = src.slice(0, lastLine + from);\n return html;\n}\n\n/**\n * Render for a document previewer: every block carries `data-sc-block`, so a\n * DOM selection resolves to a source span by walking up to the nearest one.\n *\n * Kept separate from renderMarkdown rather than added as an option, because\n * assistant prose has nothing to address and the extra attributes would be\n * noise in every message bubble.\n */\nexport function renderMarkdownWithAnchors(src: string): AnchoredMarkdown {\n const blocks = splitBlocks(src);\n const html = blocks\n .map((block, i) => {\n const rendered = renderBlock(src, block, 0);\n // Every branch of renderBlock returns markup, so the first tag always\n // exists; the anchor rides on it instead of an extra wrapper element,\n // which keeps the DOM (and therefore .sc-prose's spacing rules) unchanged.\n return rendered.replace(/^(\\s*<[a-z][a-z0-9]*)/i, `$1 data-sc-block=\"${i}\"`);\n })\n .join(\"\");\n return { html, blocks };\n}\n"],"mappings":";AAOA,IAAM,UAAU,IAAI,KAAK,aAAa,QAAW,EAAE,UAAU,WAAW,uBAAuB,EAAE,CAAC;AAClG,IAAM,QAAQ,IAAI,KAAK,aAAa,QAAW,EAAE,uBAAuB,EAAE,CAAC;AAC3E,IAAM,UAAU,IAAI,KAAK,aAAa,QAAW,EAAE,uBAAuB,GAAG,aAAa,MAAM,CAAC;AACjG,IAAM,YAAY,IAAI,KAAK,aAAa,QAAW,EAAE,uBAAuB,GAAG,aAAa,MAAM,CAAC;AACnG,IAAM,UAAU,CAAC,OAAuB,KAAK,IAAI,CAAC,IAAI,IAAI,YAAY,SAAS,OAAO,CAAC;AAEhF,SAAS,YAAY,OAAgB,SAA0B,QAAgB;AACpF,MAAI,SAAS,KAAM,QAAO;AAE1B,UAAQ,QAAQ;AAAA,IACd,KAAK,UAAU;AACb,YAAM,IAAI,OAAO,KAAK;AACtB,UAAI,CAAC,OAAO,SAAS,CAAC,EAAG,QAAO,OAAO,KAAK;AAG5C,aAAO,KAAK,IAAI,CAAC,KAAK,MAAU,QAAQ,OAAO,CAAC,IAAI,MAAM,OAAO,CAAC;AAAA,IACpE;AAAA,IACA,KAAK,YAAY;AACf,YAAM,IAAI,OAAO,KAAK;AACtB,UAAI,CAAC,OAAO,SAAS,CAAC,EAAG,QAAO,OAAO,KAAK;AAC5C,YAAM,MAAM,KAAK,IAAI,CAAC;AAEtB,YAAM,SAAS,OAAO,IAAI,IAAI,OAAO,OAAO,IAAI;AAGhD,YAAM,MAAM,OAAO,OAAQ,OAAO,UAAU,CAAC,IAAI,IAAI;AACrD,aAAO,IAAI,EAAE,eAAe,QAAW,EAAE,uBAAuB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EAC7E,CAAC,EACA,KAAK,EAAE;AACV,SAAO,EAAE,MAAM,OAAO;AACxB;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supersolutions/super-chat-ui-core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Framework-free helpers shared by superchat UI bindings: markdown rendering (incl. streaming), value formatting and thread export.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "SUPER SOLUTION LABS INC",
|
|
7
|
+
"homepage": "https://github.com/Super-Solution/super-chat/tree/main/packages/ui-core#readme",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/Super-Solution/super-chat/issues"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"agent",
|
|
13
|
+
"llm",
|
|
14
|
+
"ai",
|
|
15
|
+
"markdown",
|
|
16
|
+
"formatting",
|
|
17
|
+
"export",
|
|
18
|
+
"ui",
|
|
19
|
+
"framework-agnostic"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"module": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"LICENSE",
|
|
36
|
+
"NOTICE"
|
|
37
|
+
],
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "https://github.com/Super-Solution/super-chat.git",
|
|
41
|
+
"directory": "packages/ui-core"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@supersolutions/super-chat-core": "0.1.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"tsup": "^8.3.5",
|
|
51
|
+
"typescript": "^5.7.2"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsup",
|
|
55
|
+
"typecheck": "tsc --noEmit"
|
|
56
|
+
}
|
|
6
57
|
}
|