PageSourceSearch

https://typst-wasm-playground-cloudflare.will-bradshaw50.workers.dev/assets/routes-D_xMnoSf.js

js typst-wasm-playground-cloudflare.will-bradshaw50.workers.dev collected 2026-10-03 08:12:01 UTC 2,816 bytes, 1 lines download raw bytes

1import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./index-CsK9UCET.js";var s=a(r(),1),c=e=>{let t=(0,s.useRef)(null);return(0,s.useEffect)(()=>()=>{t.current?.abort()},[]),{run:(...n)=>{t.current?.abort();let r=new AbortController;t.current=r,e(r.signal,...n).finally(()=>{t.current===r&&(t.current=null)})}}},l=e(),u=[`html`,`pdf`,`png`,`svg`];function d({result:e}){let[t,n]=(0,s.useState)(null);switch((0,s.useEffect)(()=>{if(typeof URL>`u`)return;let t=e.format===`pdf`?URL.createObjectURL(new Blob([e.output],{type:`application/pdf`})):e.format===`png`?e.pages.map(e=>URL.createObjectURL(new Blob([e.output],{type:`image/png`}))):null;return n(t),()=>{for(let e of t?Array.isArray(t)?t:[t]:[])URL.revokeObjectURL(e)}},[e]),e.format){case`html`:return(0,l.jsx)(`article`,{className:`preview`,dangerouslySetInnerHTML:{__html:e.output}});case`svg`:return(0,l.jsx)(`div`,{className:`preview output-pages`,children:e.pages.map(e=>(0,l.jsx)(`article`,{dangerouslySetInnerHTML:{__html:e.output}},e.page))});case`png`:return(0,l.jsx)(`div`,{className:`preview output-pages`,children:Array.isArray(t)&&e.pages.map((e,n)=>(0,l.jsx)(`img`,{src:t[n],alt:`Page ${e.page}`},e.page))});case`pdf`:return(0,l.jsx)(`div`,{className:`preview pdf-preview`,children:typeof t==`string`?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`object`,{data:t,type:`application/pdf`}),(0,l.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,children:`Open PDF`})]}):null})}}function f(){let[e,r]=(0,s.useState)(o.useLoaderData()),[a,f]=(0,s.useState)(n),[p,m]=(0,s.useState)(`html`),[h,g]=(0,s.useState)(null),[_,v]=(0,s.useState)(!1),{run:y}=c(async(e,n,a)=>{v(!0),await i(n,a).then(t=>{e.aborted||(r(t),g(null))}).catch(n=>{e.aborted||g(t(n))}),e.aborted||v(!1)}),b=(0,s.useMemo)(()=>_?`Compiling`:h?`Compile error`:`${p.toUpperCase()} preview`,[h,p,_]);return(0,l.jsxs)(`main`,{className:`shell`,children:[(0,l.jsxs)(`section`,{className:`pane`,children:[(0,l.jsx)(`div`,{className:`pane-header`,children:(0,l.jsx)(`h1`,{children:`Typst editor`})}),(0,l.jsx)(`textarea`,{className:`source`,spellCheck:!1,value:a,onChange:e=>{let t=e.target.value;f(t),y(t,p)}})]}),(0,l.jsxs)(`section`,{className:`pane`,children:[(0,l.jsxs)(`div`,{className:`pane-header`,children:[(0,l.jsx)(`h2`,{children:`Preview`}),(0,l.jsxs)(`label`,{className:`format-select`,children:[`Output`,` `,(0,l.jsx)(`select`,{value:p,onChange:e=>{let t=e.target.value;m(t),y(a,t)},children:u.map(e=>(0,l.jsx)(`option`,{value:e,children:e.toUpperCase()},e))})]}),(0,l.jsx)(`span`,{className:`status`,children:b})]}),h?(0,l.jsx)(`pre`,{className:`error`,children:h}):null,(0,l.jsx)(d,{result:e}),(0,l.jsx)(`div`,{className:`diagnostics`,children:e.diagnostics.length===0?``:`${e.diagnostics.length} diagnostic${e.diagnostics.length===1?``:`s`}`})]})]})}export{f as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.