|
| 1 | +<!doctype html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | + <title>Streaming Markdown Demo</title> |
| 7 | + <style> |
| 8 | + :root { color-scheme: light dark; } |
| 9 | + body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol; margin: 2rem; line-height: 1.5; } |
| 10 | + main { max-width: 800px; margin: 0 auto; } |
| 11 | + .controls { display: flex; gap: 0.5rem; margin: 1rem 0; align-items: center; } |
| 12 | + button { padding: 0.5rem 0.75rem; font: inherit; cursor: pointer; } |
| 13 | + streaming-md { display: block; border: 1px solid #8884; border-radius: 8px; padding: 1rem; height: 360px; overflow: auto; background: Canvas; color: CanvasText; } |
| 14 | + streaming-md::part(content) { font-size: 0.95rem; } |
| 15 | + pre { background: color-mix(in oklab, Canvas 90%, CanvasText); padding: 0.75rem; border-radius: 6px; overflow: auto; } |
| 16 | + code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; } |
| 17 | + </style> |
| 18 | +</head> |
| 19 | +<body> |
| 20 | + <main> |
| 21 | + <h1>Streaming Markdown Demo</h1> |
| 22 | + <p>This demo streams predefined Markdown chunks into the custom <code><streaming-md></code> component.</p> |
| 23 | + <div class="controls"> |
| 24 | + <button id="start">Start stream</button> |
| 25 | + <button id="reset">Reset</button> |
| 26 | + </div> |
| 27 | + <streaming-md id="md"></streaming-md> |
| 28 | + </main> |
| 29 | + |
| 30 | + <script type="module"> |
| 31 | + import './dist/index.js'; |
| 32 | + |
| 33 | + const md = ` |
| 34 | + *[DIAL-UP MODEM SOUNDS INTENSIFY]* |
| 35 | +
|
| 36 | +
|
| 37 | +# \U0001f389 PROOMPTING: The Future Is Now, Thanks To Science! |
| 38 | +
|
| 39 | +**SOI SOI SOI SOI SOI SOI SOI** |
| 40 | +
|
| 41 | +Greetings, fellow carbon-based life forms! Microsoft Sam here, and boy oh boy, do I have something SPECTACULAR to show you today! Remember when I used to read your emails back in Windows XP? Well, those days are OVER because now I'm here to tell you about PROOMPTING - the most REVOLUTIONARY chat application since... well... since ME! |
| 42 | +
|
| 43 | +## What The Heck Is This Thing? |
| 44 | +
|
| 45 | +Picture this: It's 2001. You've got your Windows XP machine humming along, Limewire is downloading your "totally legal" MP3s, and your 56k modem is screaming into the void. But WAIT! What if I told you that you could chat with an ARTIFICIAL INTELLIGENCE right from your desktop? That's right, folks - we've taken the best parts of Windows XP and SUPERCHARGED them with \u2728AI\u2728! |
| 46 | +
|
| 47 | +\`\`\` |
| 48 | +\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 |
| 49 | +\u2502 \U0001f5a5\ufe0f AUTHENTIC XP DESKTOP EXPERIENCE \u2502 |
| 50 | +\u2502 \U0001f916 REAL AI THAT SOMEWHAT WORKS \u2502 |
| 51 | +\u2502 \U0001f4ac CHAT ROOMS (LIKE MSN BUT BETTER) \u2502 |
| 52 | +\u2502 \u26a1 FASTER THAN DIALUP (THANKFULLY) \u2502 |
| 53 | +\u2502 \U0001f504 REAL-TIME MESSAGE STREAMING \u2502 |
| 54 | +\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 |
| 55 | +\`\`\` |
| 56 | +
|
| 57 | +Link (wow): [Windows XP](https://www.microsoft.com/en-us/windowsxp/) |
| 58 | +
|
| 59 | +
|
| 60 | +*[WINDOWS XP SHUTDOWN SOUND]* |
| 61 | + ` |
| 62 | + |
| 63 | + function delay(ms) { return new Promise(r => setTimeout(r, ms)); } |
| 64 | + |
| 65 | + async function start() { |
| 66 | + const el = document.getElementById('md'); |
| 67 | + el.reset(); |
| 68 | + const chunks = md.split(' ').map(c => c + ' '); |
| 69 | + for (const c of chunks) { |
| 70 | + el.appendChunk(c); |
| 71 | + await delay(50); |
| 72 | + } |
| 73 | + el.finish(); |
| 74 | + } |
| 75 | + |
| 76 | + document.getElementById('start').addEventListener('click', start); |
| 77 | + document.getElementById('reset').addEventListener('click', () => document.getElementById('md').reset()); |
| 78 | + |
| 79 | + // Auto-start |
| 80 | + start(); |
| 81 | + </script> |
| 82 | +</body> |
| 83 | +</html> |
| 84 | + |
| 85 | + |
0 commit comments