@smoothstream/vue 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Smoothstream contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # @smoothstream/vue
2
+
3
+ Deterministic, paced streaming Markdown for Vue 3 and Nuxt.
4
+
5
+ ```sh
6
+ npm install @smoothstream/vue vue
7
+ ```
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ import { Smoothstream } from "@smoothstream/vue";
12
+ </script>
13
+
14
+ <template>
15
+ <Smoothstream
16
+ :markdown="message.content"
17
+ :receiving="message.isStreaming"
18
+ />
19
+ </template>
20
+ ```
21
+
22
+ Streaming mode is the default. Render completed content such as previous chat
23
+ messages immediately with `mode="static"`:
24
+
25
+ ```vue
26
+ <Smoothstream :markdown="previousMessage.content" mode="static" />
27
+ ```
28
+
29
+ Each mounted component represents one append-only response. Give a different
30
+ response a new Vue `key`. Static rendering is SSR-safe; browser-only playback,
31
+ resource loading, highlighting, and clipboard work begin after mounting.
32
+
33
+ Default reveal mechanics and prose styling are loaded automatically.
package/dist/base.css ADDED
@@ -0,0 +1,349 @@
1
+ @keyframes smoothstream-text-in {
2
+ from {
3
+ opacity: 0;
4
+ }
5
+
6
+ to {
7
+ opacity: 1;
8
+ }
9
+ }
10
+
11
+ @keyframes smoothstream-block-in {
12
+ from {
13
+ opacity: 0;
14
+ transform: translateY(8px);
15
+ }
16
+
17
+ to {
18
+ opacity: 1;
19
+ transform: translateY(0);
20
+ }
21
+ }
22
+
23
+ @keyframes smoothstream-rule-in {
24
+ from {
25
+ transform: scaleX(0);
26
+ }
27
+
28
+ to {
29
+ transform: scaleX(1);
30
+ }
31
+ }
32
+
33
+ @keyframes smoothstream-table-row-in {
34
+ from {
35
+ opacity: 0;
36
+ }
37
+
38
+ to {
39
+ opacity: 1;
40
+ }
41
+ }
42
+
43
+ @keyframes smoothstream-marker-in {
44
+ from {
45
+ color: transparent;
46
+ }
47
+ }
48
+
49
+ @keyframes smoothstream-task-in {
50
+ from {
51
+ opacity: 0;
52
+ }
53
+ }
54
+
55
+ @keyframes smoothstream-image-in {
56
+ from {
57
+ filter: blur(4px);
58
+ opacity: 0;
59
+ }
60
+
61
+ to {
62
+ filter: blur(0);
63
+ opacity: 1;
64
+ }
65
+ }
66
+
67
+ [data-smoothstream-mode="streaming"][data-smoothstream-motion="animate"] {
68
+ font-kerning: none;
69
+ }
70
+
71
+ /*
72
+ * The invisible generated suffix lets the browser apply the consumer's normal
73
+ * line-breaking rules to a buffered word before its first character appears.
74
+ */
75
+ [data-smoothstream-remainder]::after {
76
+ content: attr(data-smoothstream-remainder);
77
+ visibility: hidden;
78
+ }
79
+
80
+ [data-smoothstream-kind="text"],
81
+ [data-smoothstream-kind="inline"],
82
+ [data-smoothstream-kind="link"] {
83
+ animation: smoothstream-text-in var(--smoothstream-duration, 180ms)
84
+ cubic-bezier(0.22, 1, 0.36, 1) var(--smoothstream-animation-delay, 0ms) both;
85
+ }
86
+
87
+ [data-smoothstream-kind="heading"],
88
+ [data-smoothstream-kind="list-item"] {
89
+ animation: smoothstream-block-in var(--smoothstream-duration, 260ms)
90
+ cubic-bezier(0.22, 1, 0.36, 1) var(--smoothstream-animation-delay, 0ms) both;
91
+ }
92
+
93
+ [data-smoothstream-kind="block"] {
94
+ transform-origin: center;
95
+ animation: smoothstream-rule-in var(--smoothstream-duration, 1200ms)
96
+ cubic-bezier(0.16, 1, 0.3, 1) var(--smoothstream-animation-delay, 0ms) both;
97
+ }
98
+
99
+ [data-smoothstream-kind="table-row"] {
100
+ animation: smoothstream-table-row-in var(--smoothstream-duration, 400ms)
101
+ cubic-bezier(0.22, 1, 0.36, 1) var(--smoothstream-animation-delay, 0ms) both;
102
+ }
103
+
104
+ [data-smoothstream-kind="image"] {
105
+ animation: smoothstream-image-in var(--smoothstream-duration, 400ms)
106
+ cubic-bezier(0.22, 1, 0.36, 1) var(--smoothstream-animation-delay, 0ms) both;
107
+ }
108
+
109
+ [data-smoothstream-marker="active"]::marker {
110
+ animation: smoothstream-marker-in var(--smoothstream-duration, 400ms)
111
+ cubic-bezier(0.22, 1, 0.36, 1) var(--smoothstream-animation-delay, 0ms) both;
112
+ }
113
+
114
+ [data-smoothstream-task="active"] {
115
+ animation: smoothstream-task-in var(--smoothstream-duration, 400ms)
116
+ cubic-bezier(0.22, 1, 0.36, 1) var(--smoothstream-animation-delay, 0ms) both;
117
+ }
118
+
119
+ [data-smoothstream-code-copy] {
120
+ visibility: hidden;
121
+ opacity: 0;
122
+ pointer-events: none;
123
+ transition: opacity var(--smoothstream-duration, 400ms)
124
+ cubic-bezier(0.22, 1, 0.36, 1);
125
+ }
126
+
127
+ [data-smoothstream-code-copy][data-smoothstream-ready="true"] {
128
+ visibility: visible;
129
+ opacity: 1;
130
+ pointer-events: auto;
131
+ }
132
+
133
+ /*
134
+ * Enhanced code blocks remain a real <pre>, so consumer pre styles wrap the
135
+ * toolbar and code together. These rules provide only the component structure
136
+ * needed by any optional highlighter.
137
+ */
138
+ pre[data-smoothstream-code-block] {
139
+ overflow: hidden;
140
+ background-color: var(
141
+ --smoothstream-code-background,
142
+ var(
143
+ --smoothstream-shiki-background,
144
+ var(--smoothstream-code-default-background, transparent)
145
+ )
146
+ );
147
+ color: var(
148
+ --smoothstream-code-color,
149
+ var(
150
+ --smoothstream-shiki-color,
151
+ var(--smoothstream-code-default-color, inherit)
152
+ )
153
+ );
154
+ font-family: inherit;
155
+ font-size: inherit;
156
+ }
157
+
158
+ [data-smoothstream-code-toolbar] {
159
+ display: flex;
160
+ align-items: center;
161
+ min-width: 0;
162
+ justify-content: space-between;
163
+ gap: 1rem;
164
+ color: inherit;
165
+ white-space: normal;
166
+ }
167
+
168
+ [data-smoothstream-code-language] {
169
+ min-width: 0;
170
+ overflow: hidden;
171
+ font-size: var(--smoothstream-code-language-font-size, 0.875em);
172
+ text-overflow: ellipsis;
173
+ white-space: nowrap;
174
+ }
175
+
176
+ [data-smoothstream-code-copy] {
177
+ display: grid;
178
+ inline-size: var(--smoothstream-code-copy-button-size, max(1.75rem, 1.75em));
179
+ block-size: var(--smoothstream-code-copy-button-size, max(1.75rem, 1.75em));
180
+ flex: 0 0 auto;
181
+ place-items: center;
182
+ padding: 0;
183
+ appearance: none;
184
+ border: 0;
185
+ background: transparent;
186
+ color: inherit;
187
+ cursor: pointer;
188
+ font: inherit;
189
+ }
190
+
191
+ pre[data-smoothstream-code-block] > code {
192
+ display: block;
193
+ max-width: 100%;
194
+ overflow-x: auto;
195
+ }
196
+
197
+ /*
198
+ * Without a language label, the toolbar no longer reserves a header row. The
199
+ * copy control floats above the scrollport while trailing inline padding lets
200
+ * every line scroll completely clear of it.
201
+ */
202
+ pre[data-smoothstream-code-block][data-smoothstream-code-language-hidden] {
203
+ position: relative;
204
+ }
205
+
206
+ pre[data-smoothstream-code-block][data-smoothstream-code-language-hidden]
207
+ [data-smoothstream-code-toolbar] {
208
+ position: absolute;
209
+ z-index: 1;
210
+ inset-block-start: var(--smoothstream-code-copy-inset-block, 0.45rem);
211
+ inset-inline-end: var(--smoothstream-code-copy-inset-inline, 0.45rem);
212
+ min-height: 0;
213
+ padding: 0;
214
+ pointer-events: none;
215
+ }
216
+
217
+ pre[data-smoothstream-code-block][data-smoothstream-code-language-hidden]
218
+ [data-smoothstream-code-language] {
219
+ display: none;
220
+ }
221
+
222
+ pre[data-smoothstream-code-block][data-smoothstream-code-language-hidden]
223
+ [data-smoothstream-code-copy] {
224
+ margin-inline-end: 0;
225
+ border-radius: var(--smoothstream-code-copy-border-radius, 0.375rem);
226
+ background-color: var(
227
+ --smoothstream-code-copy-background,
228
+ color-mix(
229
+ in srgb,
230
+ var(
231
+ --smoothstream-code-background,
232
+ var(
233
+ --smoothstream-shiki-background,
234
+ var(--smoothstream-code-default-background, transparent)
235
+ )
236
+ )
237
+ 20%,
238
+ transparent
239
+ )
240
+ );
241
+ backdrop-filter: blur(var(--smoothstream-code-copy-backdrop-blur, 8px));
242
+ -webkit-backdrop-filter: blur(
243
+ var(--smoothstream-code-copy-backdrop-blur, 4px)
244
+ );
245
+ }
246
+
247
+ pre[data-smoothstream-code-block][data-smoothstream-code-language-hidden]
248
+ > code {
249
+ box-sizing: border-box;
250
+ inline-size: 100%;
251
+ padding-inline-end: calc(
252
+ var(--smoothstream-code-padding-inline, 0px) +
253
+ var(--smoothstream-code-copy-button-size, max(1.75rem, 1.75em)) +
254
+ var(--smoothstream-code-copy-clearance, 0.5rem)
255
+ );
256
+ }
257
+
258
+ [data-smoothstream-code-icon-swap] {
259
+ position: relative;
260
+ display: inline-grid;
261
+ }
262
+
263
+ [data-smoothstream-code-icon] {
264
+ inline-size: var(--smoothstream-code-copy-icon-size, max(14px, 1em));
265
+ block-size: var(--smoothstream-code-copy-icon-size, max(14px, 1em));
266
+ grid-area: 1 / 1;
267
+ transition:
268
+ opacity var(--smoothstream-icon-swap-duration, 250ms) ease-in-out,
269
+ filter var(--smoothstream-icon-swap-duration, 250ms) ease-in-out,
270
+ transform var(--smoothstream-icon-swap-duration, 250ms) ease-in-out;
271
+ will-change: opacity, filter, transform;
272
+ }
273
+
274
+ [data-smoothstream-code-icon-swap][data-state="copy"]
275
+ [data-smoothstream-code-icon="copy"],
276
+ [data-smoothstream-code-icon-swap][data-state="check"]
277
+ [data-smoothstream-code-icon="check"] {
278
+ opacity: 1;
279
+ filter: blur(0);
280
+ transform: scale(1);
281
+ }
282
+
283
+ [data-smoothstream-code-icon-swap][data-state="copy"]
284
+ [data-smoothstream-code-icon="check"],
285
+ [data-smoothstream-code-icon-swap][data-state="check"]
286
+ [data-smoothstream-code-icon="copy"] {
287
+ opacity: 0;
288
+ filter: blur(2px);
289
+ transform: scale(0.25);
290
+ }
291
+
292
+ /*
293
+ * Table containment is rendering behavior rather than optional typography.
294
+ * The shell stays fixed while only the nested viewport scrolls.
295
+ */
296
+ [data-smoothstream-table-shell] {
297
+ width: fit-content;
298
+ max-width: 100%;
299
+ overflow: hidden;
300
+ }
301
+
302
+ [data-smoothstream-table-scroll] {
303
+ max-width: 100%;
304
+ overflow-x: auto;
305
+ overscroll-behavior-inline: contain;
306
+ }
307
+
308
+ [data-smoothstream-table-scroll] > table {
309
+ width: fit-content;
310
+ max-width: none;
311
+ margin: 0;
312
+ }
313
+
314
+ [data-smoothstream-table-scroll] th {
315
+ overflow-wrap: normal;
316
+ white-space: nowrap;
317
+ }
318
+
319
+ [data-smoothstream-table-scroll] td {
320
+ overflow-wrap: normal;
321
+ }
322
+
323
+ [data-smoothstream-motion="none"] [data-smoothstream-code-copy],
324
+ [data-smoothstream-motion="none"] [data-smoothstream-code-icon-swap],
325
+ [data-smoothstream-motion="none"] [data-smoothstream-code-icon] {
326
+ transition: none;
327
+ }
328
+
329
+ @media (prefers-reduced-motion: reduce) {
330
+ [data-smoothstream-reduced-motion="system"] [data-smoothstream-unit],
331
+ [data-smoothstream-reduced-motion="system"]
332
+ [data-smoothstream-marker="active"]::marker,
333
+ [data-smoothstream-reduced-motion="system"] [data-smoothstream-task="active"],
334
+ [data-smoothstream-reduced-motion="system"] [data-smoothstream-code-copy],
335
+ [data-smoothstream-reduced-motion="system"]
336
+ [data-smoothstream-code-icon-swap],
337
+ [data-smoothstream-reduced-motion="system"] [data-smoothstream-code-icon],
338
+ [data-smoothstream-reduced-motion="always"] [data-smoothstream-unit],
339
+ [data-smoothstream-reduced-motion="always"]
340
+ [data-smoothstream-marker="active"]::marker,
341
+ [data-smoothstream-reduced-motion="always"] [data-smoothstream-task="active"],
342
+ [data-smoothstream-reduced-motion="always"] [data-smoothstream-code-copy],
343
+ [data-smoothstream-reduced-motion="always"]
344
+ [data-smoothstream-code-icon-swap],
345
+ [data-smoothstream-reduced-motion="always"] [data-smoothstream-code-icon] {
346
+ animation: none;
347
+ transition: none;
348
+ }
349
+ }
@@ -0,0 +1,112 @@
1
+ import * as _smoothstream_core from '@smoothstream/core';
2
+ import { MarkdownReveal, CodeHighlighter } from '@smoothstream/core';
3
+ export { CodeHighlightLine, CodeHighlightPalette, CodeHighlightRequest, CodeHighlightResult, CodeHighlightToken, CodeHighlighter, CodeTokenStyle } from '@smoothstream/core';
4
+ import * as vue from 'vue';
5
+ import { PropType, VNode } from 'vue';
6
+
7
+ type SmoothstreamMode = "streaming" | "static";
8
+ type SmoothstreamReducedMotion = "system" | "always" | "never";
9
+ type SmoothstreamReveal = MarkdownReveal;
10
+ interface SmoothstreamProps {
11
+ /** Optional syntax highlighter for fenced code blocks. */
12
+ codeHighlighter?: CodeHighlighter;
13
+ /** Milliseconds spent animating each revealed character or word. @default 1000 */
14
+ duration?: number;
15
+ /** Base cadence in milliseconds; word mode preserves it while grouping characters. @default 3 */
16
+ interval?: number;
17
+ /** Accumulated Markdown snapshot to present. */
18
+ markdown?: string;
19
+ /** Progressively reveal streaming content or render completed Markdown immediately. @default "streaming" */
20
+ mode?: SmoothstreamMode;
21
+ /** Whether more Markdown may still arrive. */
22
+ receiving?: boolean;
23
+ /** Reduced-motion policy: follow the system preference, always reduce, or never reduce. @default "system" */
24
+ reducedMotion?: SmoothstreamReducedMotion;
25
+ /** Reveal flowing text by character or by complete word. @default "character" */
26
+ reveal?: SmoothstreamReveal;
27
+ /** Disable Smoothstream's default prose theme while retaining reveal and layout behavior. */
28
+ unstyled?: boolean;
29
+ }
30
+
31
+ declare const Smoothstream: vue.DefineComponent<vue.ExtractPropTypes<{
32
+ codeHighlighter: PropType<CodeHighlighter | undefined>;
33
+ duration: {
34
+ default: number;
35
+ type: NumberConstructor;
36
+ };
37
+ interval: {
38
+ default: number;
39
+ type: NumberConstructor;
40
+ };
41
+ markdown: {
42
+ default: string;
43
+ type: StringConstructor;
44
+ };
45
+ mode: {
46
+ default: string;
47
+ type: PropType<SmoothstreamMode>;
48
+ };
49
+ receiving: {
50
+ default: boolean;
51
+ type: BooleanConstructor;
52
+ };
53
+ reducedMotion: {
54
+ default: string;
55
+ type: PropType<SmoothstreamReducedMotion>;
56
+ };
57
+ reveal: {
58
+ default: string;
59
+ type: PropType<SmoothstreamReveal>;
60
+ };
61
+ unstyled: {
62
+ default: boolean;
63
+ type: BooleanConstructor;
64
+ };
65
+ }>, () => VNode<vue.RendererNode, vue.RendererElement, {
66
+ [key: string]: any;
67
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
68
+ codeHighlighter: PropType<CodeHighlighter | undefined>;
69
+ duration: {
70
+ default: number;
71
+ type: NumberConstructor;
72
+ };
73
+ interval: {
74
+ default: number;
75
+ type: NumberConstructor;
76
+ };
77
+ markdown: {
78
+ default: string;
79
+ type: StringConstructor;
80
+ };
81
+ mode: {
82
+ default: string;
83
+ type: PropType<SmoothstreamMode>;
84
+ };
85
+ receiving: {
86
+ default: boolean;
87
+ type: BooleanConstructor;
88
+ };
89
+ reducedMotion: {
90
+ default: string;
91
+ type: PropType<SmoothstreamReducedMotion>;
92
+ };
93
+ reveal: {
94
+ default: string;
95
+ type: PropType<SmoothstreamReveal>;
96
+ };
97
+ unstyled: {
98
+ default: boolean;
99
+ type: BooleanConstructor;
100
+ };
101
+ }>> & Readonly<{}>, {
102
+ mode: SmoothstreamMode;
103
+ duration: number;
104
+ interval: number;
105
+ markdown: string;
106
+ receiving: boolean;
107
+ reducedMotion: SmoothstreamReducedMotion;
108
+ reveal: _smoothstream_core.MarkdownReveal;
109
+ unstyled: boolean;
110
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
111
+
112
+ export { Smoothstream, type SmoothstreamMode, type SmoothstreamProps, type SmoothstreamReducedMotion, type SmoothstreamReveal };