diff --git a/docs/docs/index.md b/docs/docs/index.md index ea9ba17..01b867d 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -160,12 +160,58 @@ Replaces pywrangler. It drops vendored files your Worker never imports before ea -```sh -uvx wynd init # write a new crosswind-workers project -uvx wynd dev # install packages for the Worker's Python, then wrangler dev -uvx wynd deploy # prune unused packages, then wrangler deploy -uvx wynd tail # anything else goes to Wrangler unchanged -``` +
$ uvx wynd init my-worker
+  1) crosswind-workers
+  2) workers-runtime-sdk
+Workers SDK [1]: 1
+  1) containers-py
+  2) cf-agents
+Add SDKs, comma-separated: 
+wynd: wrote src/env.py
+wynd: created my-worker. Run `wynd dev` in ~/my-worker to serve it.
+​
+$ cd my-worker
+$ uvx wynd dev
+ ⛅️ wrangler 4.129.0
+───────────────────────────────────────────────────
+╭──────────────────────────╮
+│  [b] open a browser      │
+│  [d] open devtools       │
+│  [e] open local explorer │
+│  [t] start tunnel        │
+│  [c] clear console       │
+│  [x] to exit             │
+╰──────────────────────────╯
+Attaching additional modules:
+┌────────────────────┬────────┬────────────┐
+│ Name               │ Type   │ Size       │
+├────────────────────┼────────┼────────────┤
+│ env.py             │ python │ 0.13 KiB   │
+├────────────────────┼────────┼────────────┤
+│ Vendored Modules   │        │ 131.24 KiB │
+├────────────────────┼────────┼────────────┤
+│ Total (43 modules) │        │ 131.37 KiB │
+└────────────────────┴────────┴────────────┘
+⎔ Starting local server...
+[wrangler:info] Ready on http://localhost:8787
+​
+$ uvx wynd deploy --dry-run
+wynd: python_modules is 134,389 bytes, 85,098 after pruning (49,291 fewer). Each file's decision is in .wynd/shake.txt.
+ ⛅️ wrangler 4.129.0
+───────────────────────────────────────────────────
+Attaching additional modules:
+┌────────────────────┬────────┬───────────┐
+│ Name               │ Type   │ Size      │
+├────────────────────┼────────┼───────────┤
+│ env.py             │ python │ 0.13 KiB  │
+├────────────────────┼────────┼───────────┤
+│ Vendored Modules   │        │ 83.10 KiB │
+├────────────────────┼────────┼───────────┤
+│ Total (37 modules) │        │ 83.24 KiB │
+└────────────────────┴────────┴───────────┘
+Total Upload: 83.42 KiB / gzip: 19.53 KiB
+No bindings found.
+--dry-run: exiting now.
diff --git a/docs/docs/javascripts/home.js b/docs/docs/javascripts/home.js index 7b0995a..512e0fe 100644 --- a/docs/docs/javascripts/home.js +++ b/docs/docs/javascripts/home.js @@ -130,3 +130,113 @@ document.querySelector(".cw-demo button")?.addEventListener("click", (event) => frame.allow = "fullscreen; autoplay; gamepad"; event.currentTarget.parentElement.replaceChildren(frame); }); + +// Wynd pane: replays the transcript as a terminal session. The static transcript stays +// in the page for screen readers and is what shows without JS or with reduced motion. +(() => { + const box = document.querySelector(".cw-term"); + const code = box?.querySelector("code"); + if (!code || matchMedia("(prefers-reduced-motion: reduce)").matches) return; + + const lines = code.innerHTML.split("\n"); + const live = code.cloneNode(false); + live.setAttribute("aria-hidden", "true"); + code.classList.add("cw-term__sr"); + code.after(live); + + const pane = box.closest(".cw-pane"); + const button = document.createElement("button"); + button.type = "button"; + button.className = "cw-term__control"; + pane.append(button); + + const caret = document.createElement("span"); + caret.className = "cw-term__caret"; + const sleep = (ms) => new Promise((done) => setTimeout(done, ms)); + const isBox = (text) => /^[│├┌└╭╰─]/.test(text); + let run = 0; + let pinned = true; // follow new output until the reader scrolls up + + box.addEventListener("scroll", () => { + pinned = box.scrollHeight - box.scrollTop - box.clientHeight < 8; + }); + const follow = () => { + if (pinned) box.scrollTop = box.scrollHeight; + }; + + function addLine(html) { + const line = document.createElement("span"); + line.className = "cw-term__line"; + line.innerHTML = html; + live.append(line, "\n"); + return line; + } + + async function play() { + const id = ++run; + const alive = () => id === run; + live.replaceChildren(); + pinned = true; + box.scrollTop = 0; + button.textContent = "Skip"; + + for (const html of lines) { + const at = html.indexOf(''); + if (at === -1) { + const text = html.replace(/<[^>]+>/g, ""); + const pause = text === "​" ? 1400 : isBox(text) ? 12 : /Ready on|Starting local/.test(text) ? 700 : 70; + await sleep(pause); + if (!alive()) return; + addLine(html); + follow(); + continue; + } + // A line the user types: show what precedes the input, then type it out + const typed = html.slice(at).replace(/<[^>]+>/g, ""); + const line = addLine(html.slice(0, at)); + const input = document.createElement("span"); + line.append(input, caret); + follow(); + caret.classList.add("is-idle"); + await sleep(typed ? 650 : 900); + caret.classList.remove("is-idle"); + for (const char of typed) { + if (!alive()) return; + input.textContent += char; + await sleep(38 + Math.random() * 60); + } + await sleep(280); + if (!alive()) return; + caret.remove(); + await sleep(typed.startsWith("uvx") ? 500 : 120); + } + finish(id); + } + + function finish(id) { + if (id !== run) return; + const line = addLine('$ '); + caret.classList.add("is-idle"); + line.append(caret); + follow(); + button.textContent = "Replay"; + } + + function skip() { + const id = ++run; + live.replaceChildren(); + for (const html of lines) addLine(html); + pinned = true; + finish(id); + } + + button.addEventListener("click", () => (button.textContent === "Skip" ? skip() : play())); + + // Start the first time the pane is on screen; a hidden pane never intersects + const seen = new IntersectionObserver(([entry]) => { + if (!entry.isIntersecting) return; + seen.disconnect(); + play(); + }, { threshold: 0.35 }); + seen.observe(box); +})(); diff --git a/docs/docs/stylesheets/home.css b/docs/docs/stylesheets/home.css index 7c36dee..f434369 100644 --- a/docs/docs/stylesheets/home.css +++ b/docs/docs/stylesheets/home.css @@ -1068,3 +1068,102 @@ display: none; } } + +/* Wynd pane: real terminal output, coloured as Rich and Wrangler print it */ +.cw-term__prompt, +.cw-term__dim { + color: var(--cw-muted); +} + +.cw-term__wynd { + color: var(--cw-accent); + font-weight: 700; +} + +.cw-term__faint { + color: var(--cw-label); +} + +.cw-term__bold { + font-weight: 700; +} + +.cw-term__head { + color: var(--cw-purple); +} + +.cw-term__ok { + color: var(--cw-accent); +} + +/* Wynd pane terminal playback (home.js). The static transcript stays for screen readers. */ +.cw-pane:has(.cw-term) { + position: relative; +} + +/* Terminal line height, so box-drawing borders join up; room below for the control */ +.md-typeset .cw-term pre > code { + padding-bottom: 2.2rem; + line-height: 1.3; +} + +.cw-term__sr { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip-path: inset(50%); + white-space: pre; +} + +.cw-term__line { + animation: cw-term-line 120ms var(--cw-ease-out); +} + +@keyframes cw-term-line { + from { + opacity: 0.35; + } +} + +.cw-term__caret { + display: inline-block; + width: 0.6em; + height: 1.2em; + margin-bottom: -0.25em; + background-color: var(--cw-accent); +} + +.cw-term__caret.is-idle { + animation: cw-term-blink 1.06s steps(1) infinite; +} + +@keyframes cw-term-blink { + 50% { + opacity: 0; + } +} + +.cw-term__control { + position: absolute; + right: 0.8rem; + bottom: 0.6rem; + padding: 0.12rem 0.45rem; + border: 1px solid var(--cw-border); + border-radius: var(--cw-radius-m); + background-color: var(--cw-elevated); + color: var(--cw-text-2); + font: 400 0.55rem/1.5 var(--md-code-font-family); + cursor: pointer; + transition: border-color var(--cw-fast), color var(--cw-fast); +} + +.cw-term__control:is(:hover, :focus-visible) { + border-color: var(--cw-border-strong); + color: var(--cw-text); +} + +.cw-term__control:focus-visible { + outline: 1px solid var(--cw-accent); + outline-offset: 2px; +}