canofold 0.3.0 → 0.3.2
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/dist/build-72JU66ZI.js +2 -0
- package/dist/{check-SPGDVG46.js → check-EJ4AQZQN.js} +2 -2
- package/dist/{chunk-EQOADO2H.js → chunk-BSFJWPWR.js} +2 -2
- package/dist/chunk-GLAK57S4.js +45 -0
- package/dist/chunk-JACOFQSH.js +2 -0
- package/dist/{chunk-OKX7SQKX.js → chunk-LGMGXZ4I.js} +22 -20
- package/dist/{chunk-KJ7FG6AY.js → chunk-LP3NAJM7.js} +4 -4
- package/dist/chunk-VMPJIE5E.js +2 -0
- package/dist/{clean-V2SP7IRD.js → clean-REXZDZX4.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/demo-engine.d.ts +4 -0
- package/dist/{deploy-47AUDPYE.js → deploy-VQKVGFX5.js} +2 -2
- package/dist/dev-4LCWVCHW.js +2 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +1 -1
- package/dist/{init-3PS74OVB.js → init-TVOVOMAO.js} +3 -3
- package/dist/{load-BG2H2Q65.js → load-4UYHBETN.js} +2 -2
- package/dist/{preview-OAMF5HXH.js → preview-FB3HCXFC.js} +2 -2
- package/dist/search-client.js +1 -1
- package/dist/styles.input.css +2 -12
- package/package.json +10 -9
- package/dist/build-UYV2L7WT.js +0 -2
- package/dist/chunk-2XMX5JW6.js +0 -2
- package/dist/chunk-ACUMTEQL.js +0 -2
- package/dist/chunk-HS5LEPRC.js +0 -45
- package/dist/dev-3C4T3COS.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a,b}from"./chunk-LGMGXZ4I.js";import"./chunk-BSFJWPWR.js";import"./chunk-LP3NAJM7.js";import"./chunk-ENPRUF6E.js";import"./chunk-XYJ2OBL3.js";import"./chunk-VMPJIE5E.js";import"./chunk-M6T5RSNJ.js";import"./chunk-JACOFQSH.js";import"./chunk-EAYVCA3Z.js";import"./chunk-JK7ZNBUA.js";import"./chunk-AYDF3IFZ.js";export{b as runBuild,a as versionSatisfies};
|
|
2
|
+
//# sourceMappingURL=build-72JU66ZI.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{d as I,f as b,k as M,l as D,m as L}from"./chunk-
|
|
1
|
+
import{d as I,f as b,k as M,l as D,m as L}from"./chunk-LP3NAJM7.js";import"./chunk-ENPRUF6E.js";import"./chunk-XYJ2OBL3.js";import{a as C,b as S,l as P}from"./chunk-VMPJIE5E.js";import"./chunk-JACOFQSH.js";import"./chunk-EAYVCA3Z.js";import{d as $}from"./chunk-JK7ZNBUA.js";import{a}from"./chunk-AYDF3IFZ.js";import{mkdtemp as N,readdir as Q,rm as q}from"fs/promises";import{tmpdir as J}from"os";import{join as W,relative as A}from"path";import{posix as y}from"path";import{analyzeMarkdown as w}from"@canofold/markdown/server/analyze";function R(e){return Array.from({length:w(e).missingCodeBlockLanguages},()=>({severity:"warning",message:"Code block is missing a language"}))}a(R,"checkCodeBlockLanguages");function B(e,n=0,o=[]){return w(e,{plugins:o}).directiveIssues.map(r=>({severity:"error",message:`${r.message}${r.line===void 0?"":` (line ${r.line+n}${r.column===void 0?"":`, column ${r.column}`})`}`}))}a(B,"checkRichDirectiveSyntax");function z(e){return typeof e.description=="string"&&e.description.trim()?[]:[{severity:"warning",message:"Frontmatter description is missing"}]}a(z,"checkFrontmatterDescription");function U(e,n){return typeof e.title=="string"&&e.title.trim()?[]:[{severity:"warning",page:n.relativePath,message:"Frontmatter title is missing"}]}a(U,"checkFrontmatterTitle");function F(e){return/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(e)}a(F,"isExternalTarget");function j(e){let n=e.indexOf("#"),o=n===-1?e:e.slice(0,n),r=n===-1?"":e.slice(n+1);return{path:o.split("?")[0]??"",fragment:r}}a(j,"splitTarget");function V(e){try{return decodeURIComponent(e)}catch{return}}a(V,"decodeFragment");function T(e,n){let o=n.split("/").map(r=>{let i=decodeURIComponent(r);if(i.includes("/")||i.includes("\\"))throw new Error("Encoded path separator");return i}).join("/");return y.normalize(y.join(y.dirname(e),o.replace(/^\.\//,"")))}a(T,"resolveRelativeTarget");function E(e){try{return`public${e.split("/").map(o=>{let r=decodeURIComponent(o);if(r.includes("/")||r.includes("\\")||r==="..")throw new Error("Invalid public path");return r}).join("/")}`}catch{return}}a(E,"publicFileFor");function H(e){return e.replace(/\.(?:md|mdx)$/i,n=>n.toLocaleLowerCase("en-US"))}a(H,"markdownExtensionKey");function G(e,n,o="",r=new Set,i=new Set,m=new Map,u=new Map,f=new Set){let c=[],k=w(e),h=new Map([...n].filter(t=>/\.(?:md|mdx)$/i.test(t)).map(t=>[H(t),t]));for(let t of k.images){let s=j(t).path;if(!s||F(s))continue;if(s.startsWith("/")){n.has(E(s)??"")||c.push({severity:"error",message:`Image target does not exist: ${s}`});continue}let g;try{g=T(o,s)}catch{c.push({severity:"error",message:`Image target does not exist: ${s}`});continue}n.has(g)||c.push({severity:"error",message:`Image target does not exist: ${s}`})}for(let t of k.links){let{path:s,fragment:g}=j(t),p=V(g);if(F(s))continue;if(!s){g&&(!p||!i.has(p))&&c.push({severity:"error",message:`Heading target does not exist: #${g}`});continue}if(s.startsWith("/")){if(n.has(E(s)??""))continue;let d;try{d=S(s)}catch{c.push({severity:"error",message:`Link target does not exist: ${s}`});continue}if(f.has(d))continue;let x=d==="/"?"/":`${d.replace(/\/+$/,"")}/`;r.has(x)?g&&(!p||!m.get(x)?.has(p))&&c.push({severity:"error",message:`Heading target does not exist: ${t}`}):c.push({severity:"error",message:`Link target does not exist: ${s}`});continue}let l;try{l=T(o,s)}catch{c.push({severity:"error",message:`Link target does not exist: ${s}`});continue}let v=(/\.mdx?$/i.test(l)?[l]:[l,`${l}.md`,`${l}.mdx`,y.join(l,"index.md"),y.join(l,"index.mdx")]).map(d=>n.has(d)?d:h.get(H(d))).find(d=>!!d);v?g&&(!p||!u.get(v)?.has(p))&&c.push({severity:"error",message:`Heading target does not exist: ${t}`}):c.push({severity:"error",message:`Link target does not exist: ${s}`})}return c}a(G,"checkLinksAndImages");function K(e){let n=new Map;for(let o of e.headings){let r=o.text.normalize("NFKC").replace(/\s+/g," ").trim().toLocaleLowerCase(e.locale);r&&n.set(r,[...n.get(r)??[],o])}return[...n.values()].filter(o=>o.length>1).map(o=>{let r=o[0];return{severity:"warning",page:e.relativePath,message:`Repeated heading "${r.text}" uses numbered anchors (${o.map(i=>`#${i.slug}`).join(", ")})`}})}a(K,"checkDuplicateHeadings");function O(e){let n=new Map;for(let r of e.pages){let i=`${r.version}:${C(r.relativePath,r.locale)}`;n.set(i,(n.get(i)??new Set).add(r.locale))}let o=[];for(let[r,i]of n)for(let m of e.locales)if(!i.has(m)){let[u,...f]=r.split(":");o.push({severity:"warning",message:`Missing ${m} translation for ${f.join(":")} in version ${u}`})}return o}a(O,"checkMissingTranslations");async function X(e){let n=new Set;async function o(r){let i=await Q(r,{withFileTypes:!0});for(let m of i){let u=W(r,m.name);if(m.isDirectory())await o(u);else{if(m.isSymbolicLink())throw new Error(`Documentation files must not use symbolic links: ${A(e,u)}`);n.add(A(e,u).replace(/\\/g,"/"))}}}return a(o,"walk"),await o(e),n}a(X,"collectFiles");function Y(e){if(!e.body)return 0;let n=e.transformedSource.lastIndexOf(e.body);return n<0?0:e.transformedSource.slice(0,n).split(`
|
|
2
2
|
`).length-1}a(Y,"bodyLineOffset");async function he({cwd:e}){let n=await P(e),o=await N(W(J(),"canofold-check-")),r=await D(e,o,n.extensions).finally(()=>q(o,{recursive:!0,force:!0})),i=await b(e,n,r);await L({cwd:e,config:n,graph:i,mode:"analyze"});let m=new Set([...M(n,i),...r.publicOutputPaths]),u=new Map(await Promise.all(n.versions.items.map(async t=>[t.id,await X($(e,t.docsDir,`versions.items[${t.id}].docsDir`))]))),f=new Set(i.pages.map(t=>t.routePath)),c=new Map(i.pages.map(t=>[t.routePath,new Set(t.headings.map(s=>s.slug))])),k=new Map(i.versions.map(t=>[t.id,new Map(i.pages.filter(s=>s.version===t.id).map(s=>[s.relativePath,new Set(s.headings.map(g=>g.slug))]))])),h=[...i.pages.flatMap(t=>[...R(t.body).map(s=>({...s,page:t.relativePath})),...B(t.body,Y(t),[...n.markdown.plugins,I]).map(s=>({...s,page:t.relativePath})),...U(t.frontmatter,t),...z(t.frontmatter).map(s=>({...s,page:t.relativePath})),...G(t.body,u.get(t.version)??new Set,t.relativePath,f,new Set(t.headings.map(s=>s.slug)),c,k.get(t.version),m).map(s=>({...s,page:t.sourceRelativePath})),...K(t)]),...O(i)];for(let t of h){let s=t.page?` ${t.page}`:"";console.log(`${t.severity.toUpperCase()}:${s} ${t.message}`)}return h.some(t=>t.severity==="error")&&(process.exitCode=1),h}a(he,"runCheck");export{he as runCheck};
|
|
3
|
-
//# sourceMappingURL=check-
|
|
3
|
+
//# sourceMappingURL=check-EJ4AQZQN.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as h}from"./chunk-
|
|
1
|
+
import{a as h}from"./chunk-JACOFQSH.js";import{d as a,e as E,f as d,g as u}from"./chunk-JK7ZNBUA.js";import{a as i}from"./chunk-AYDF3IFZ.js";import{randomUUID as b}from"crypto";import{mkdir as B,open as x,readFile as p,rename as S,rm as f,stat as k,writeFile as M}from"fs/promises";import{hostname as O}from"os";import{dirname as v,join as y}from"path";var w=600*1e3,A=Math.floor(w/3);function l(t){return typeof t=="string"&&t.length>0&&!t.startsWith("/")&&!t.includes("\\")&&t.split("/").every(e=>e!==""&&e!=="."&&e!=="..")}i(l,"isSafeOutputPath");function Q(t){return a(t,".canofold/cache","build cache")}i(Q,"resolveBuildCacheRoot");function Y(t){return a(t,".canofold/tmp","temporary build files")}i(Y,"resolveBuildTemporaryRoot");function P(t){return y(t,"build-manifest.json")}i(P,"manifestPath");function R(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.fingerprint=="string"&&l(e.outputPath)&&l(e.markdownOutputPath)&&Array.isArray(e.assetOutputPaths)&&e.assetOutputPaths.every(l)}i(R,"isPageState");function j(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.fingerprint=="string"&&Number.isSafeInteger(e.size)&&Number(e.size)>=0}i(j,"isOutputState");function C(t){if(!t||typeof t!="object")return!1;let e=t;return e.schemaVersion===3&&e.canofoldVersion===h&&typeof e.buildFingerprint=="string"&&typeof e.sharedFingerprint=="string"&&!!e.pages&&typeof e.pages=="object"&&Object.values(e.pages).every(R)&&!!e.outputs&&typeof e.outputs=="object"&&Object.keys(e.outputs).length>0&&Object.keys(e.outputs).every(l)&&Object.values(e.outputs).every(j)}i(C,"isBuildManifest");async function Z(t){try{let e=JSON.parse(await p(P(t),"utf8"));return C(e)?e:void 0}catch(e){if(e.code==="ENOENT"||e instanceof SyntaxError)return;throw e}}i(Z,"readBuildManifest");async function tt(t,e){await B(t,{recursive:!0});let n=P(t),o=y(t,`.build-manifest.${b()}.tmp`);try{await M(o,`${JSON.stringify(e,null,2)}
|
|
2
2
|
`,{flag:"wx",flush:!0});try{await S(o,n)}catch(r){let s=r.code;if(s!=="EEXIST"&&s!=="EPERM")throw r;await f(n,{force:!0}),await S(o,n)}}finally{await f(o,{force:!0})}}i(tt,"writeBuildManifest");function T(t){try{return process.kill(t,0),!0}catch(e){return e.code!=="ESRCH"}}i(T,"processIsAlive");function D(t,e,n=Date.now()){if(t.hostname===O()&&typeof t.pid=="number"&&Number.isSafeInteger(t.pid)&&t.pid>0&&!T(t.pid))return!0;let o=typeof t.updatedAt=="number"?t.updatedAt:typeof t.createdAt=="number"?t.createdAt:void 0,r=o===void 0?e:Math.max(o,e);return r===void 0||!Number.isFinite(r)||r>n+w||n-r>w}i(D,"lockIsStale");function F(t,e){return JSON.stringify({ownerId:t,pid:process.pid,hostname:O(),createdAt:e})}i(F,"lockContents");async function g(t){try{return JSON.parse(await p(t,"utf8"))}catch(e){if(e.code==="ENOENT")return;throw e}}i(g,"readBuildLock");async function m(t){let e=await x(t,"wx"),n=b(),o=Date.now();try{return await e.writeFile(F(n,o)),{handle:e,path:t,ownerId:n,createdAt:o}}catch(r){throw await e.close(),await f(t,{force:!0}),r}}i(m,"createBuildLock");async function N(t){(await g(t.path))?.ownerId===t.ownerId&&await f(t.path,{force:!0})}i(N,"releaseBuildLock");async function I(t){let e,n;try{let[r,s]=await Promise.all([p(t,"utf8"),k(t)]);e=r,n=s.mtimeMs}catch(r){if(r.code==="ENOENT")return!0;throw r}let o;try{o=D(JSON.parse(e),n)}catch{o=Date.now()-n>w}if(!o)return!1;try{let[r,s]=await Promise.all([p(t,"utf8"),k(t)]);return r!==e||s.mtimeMs!==n?!1:(await f(t),!0)}catch(r){if(r.code==="ENOENT")return!0;throw r}}i(I,"removeStaleLock");async function J(t){try{return await m(t)}catch(e){if(e.code!=="EEXIST")throw e;if(!await I(t))throw new Error("Another Canofold build is already running for this project");try{return await m(t)}catch(n){throw n.code==="EEXIST"?new Error("Another Canofold build is already running for this project"):n}}}i(J,"acquireBuildLock");async function _(t){let e=v(t);await B(e,{recursive:!0});let n=y(e,"build.lock"),o=await J(`${n}.reclaim`);try{try{return await m(n)}catch(r){if(r.code!=="EEXIST")throw r;if(!await I(n))throw new Error("Another Canofold build is already running for this project");return await m(n)}}finally{await o.handle.close(),await N(o)}}i(_,"openBuildLock");async function $(t){if((await g(t.path))?.ownerId!==t.ownerId)return!1;let n=new Date;return await t.handle.utimes(n,n),!0}i($,"refreshBuildLock");async function V(t){if((await g(t.path))?.ownerId!==t.ownerId)throw new Error("Canofold build lock ownership was lost during the build")}i(V,"assertBuildLockOwned");async function et(t,e){let n=await _(t),o,r=setInterval(()=>{$(n).then(s=>{s||(o=new Error("Canofold build lock ownership was lost during the build"))}).catch(s=>{o=s})},A);r.unref();try{let s=i(()=>V(n),"assertOwned"),c=await e(s);if(o)throw o;return await s(),c}finally{clearInterval(r),await n.handle.close(),await N(n)}}i(et,"withBuildLock");async function it(t,e,n){let o=E(t,e.outputDir);await d(t,o,"outputDir"),await d(t,n,"build cache"),await u(o,n,"build cache");for(let r of e.versions.items){let s=a(t,r.docsDir,`versions.items[${r.id}].docsDir`);await d(t,s,`versions.items[${r.id}].docsDir`),await u(o,s,`versions.items[${r.id}].docsDir`),await u(n,s,`versions.items[${r.id}].docsDir`,"build cache")}for(let[r,s]of e.styles.entries()){let c=a(t,s,`styles[${r}]`);await d(t,c,`styles[${r}]`),await u(o,c,`styles[${r}]`),await u(n,c,`styles[${r}]`,"build cache")}return o}i(it,"resolveSafeOutputRoot");export{Q as a,Y as b,Z as c,tt as d,et as e,it as f};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-BSFJWPWR.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import{b as H}from"./chunk-M6T5RSNJ.js";import{c as A}from"./chunk-JK7ZNBUA.js";import{a as r}from"./chunk-AYDF3IFZ.js";import{createServer as L}from"http";import{readFile as $,realpath as T}from"fs/promises";import{extname as k,isAbsolute as z,join as y,normalize as J,relative as U,resolve as F,sep as W}from"path";var O={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".js":"text/javascript; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".json":"application/json; charset=utf-8",".txt":"text/plain; charset=utf-8",".md":"text/markdown; charset=utf-8",".svg":"image/svg+xml",".xml":"application/xml; charset=utf-8",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".pagefind":"application/wasm"};function G(t){return O[k(t).toLowerCase()]??"application/octet-stream"}r(G,"contentTypeFor");var q=15e3;function K(t){for(let n of t)n.end();t.clear()}r(K,"closeReloadClients");function E(t,n){for(let i of t)try{i.write(n)}catch{t.delete(i);try{i.end()}catch{}}}r(E,"writeReloadClients");function Q(t){E(t,`:keepalive
|
|
2
|
+
|
|
3
|
+
`)}r(Q,"heartbeatReloadClients");function D(t,n=""){let i=n.replace(/\r\n?/g,`
|
|
4
|
+
`).split(`
|
|
5
|
+
`);return`event: ${t}
|
|
6
|
+
${i.map(s=>`data: ${s}`).join(`
|
|
7
|
+
`)}
|
|
8
|
+
|
|
9
|
+
`}r(D,"formatServerSentEvent");function _(t,n="/__canofold/events"){let i=`<script type="module">
|
|
10
|
+
const source=new EventSource(${JSON.stringify(n)});
|
|
11
|
+
let connected=false,disconnected=false;
|
|
12
|
+
let overlay=null;
|
|
13
|
+
function showError(msg){
|
|
14
|
+
if(!overlay){overlay=document.createElement('dialog');overlay.style.cssText='all:initial;position:fixed;inset:0;width:100%;height:100%;border:none;background:rgba(15,15,20,.92);color:#f87171;font:14px/1.6 monospace;padding:2rem;box-sizing:border-box;z-index:2147483647;overflow:auto;white-space:pre-wrap;word-break:break-all;';document.documentElement.appendChild(overlay);}
|
|
15
|
+
overlay.textContent='\u26A0\uFE0F Build error:\\n\\n'+msg;
|
|
16
|
+
if(!overlay.open)overlay.showModal();
|
|
17
|
+
}
|
|
18
|
+
function clearError(){if(overlay&&overlay.open){overlay.close();overlay.remove();overlay=null;}}
|
|
19
|
+
function normalizeRoute(value){const path=value.split(/[?#]/,1)[0]||'/';return path.endsWith('/')?path:path+'/';}
|
|
20
|
+
async function applyPageUpdate(update){
|
|
21
|
+
const currentRoute=normalizeRoute(location.pathname);
|
|
22
|
+
if(!update.routes.some((route)=>normalizeRoute(route)===currentRoute))return true;
|
|
23
|
+
const response=await fetch(location.href,{cache:'no-store',headers:{accept:'text/html'}});
|
|
24
|
+
if(!response.ok||!(response.headers.get('content-type')||'').includes('text/html'))return false;
|
|
25
|
+
const nextDocument=new DOMParser().parseFromString(await response.text(),'text/html');
|
|
26
|
+
if(typeof window.__canofoldApplyPageDocument!=='function')return false;
|
|
27
|
+
return window.__canofoldApplyPageDocument(nextDocument,{mode:'update'});
|
|
28
|
+
}
|
|
29
|
+
source.onopen=()=>{if(connected&&disconnected){clearError();location.reload();}connected=true;disconnected=false;};
|
|
30
|
+
source.onerror=()=>{if(connected)disconnected=true;};
|
|
31
|
+
source.onmessage=()=>{clearError();location.reload();};
|
|
32
|
+
source.addEventListener('update',async(event)=>{
|
|
33
|
+
clearError();
|
|
34
|
+
try{
|
|
35
|
+
const update=JSON.parse(event.data);
|
|
36
|
+
if(update.protocol!==1||update.type!=='update'||update.mode!=='page'){location.reload();return;}
|
|
37
|
+
if(!await applyPageUpdate(update))location.reload();
|
|
38
|
+
}catch{location.reload();}
|
|
39
|
+
});
|
|
40
|
+
source.addEventListener('build-error',(e)=>showError(e.data));
|
|
41
|
+
source.addEventListener('build-ok',()=>clearError());
|
|
42
|
+
</script>`;return t.replace("</body>",`${i}</body>`)}r(_,"injectLiveReloadScript");function V(t,n="/"){if(n==="/")return t;let i=n.replace(/\/$/,"");return t===i?"/":t.startsWith(`${i}/`)?t.slice(i.length)||"/":void 0}r(V,"resolveMountedRequestPath");function X(t,n){let i=F(t),s=n.split("/").map(g=>{let c=decodeURIComponent(g);if(c==="."||c===".."||c.includes("/")||c.includes("\\")||/[\u0000-\u001f]/.test(c))throw new Error("Forbidden");return c}),f=J(s.join("/"));if(f.split(/[\\/]/).includes(".."))throw new Error("Forbidden");let v=F(y(i,f)),l=f.endsWith("/")?[y(v,"index.html")]:k(f)===""?[v,y(v,"index.html")]:[v];for(let g of l){let c=U(i,g);if(c===".."||c.startsWith(`..${W}`)||z(c))throw new Error("Forbidden")}return l}r(X,"resolveRequestCandidates");async function B(t,n){let[i,s]=await Promise.all([T(t),T(n)]);if(!A(i,s))throw new Error("Forbidden");return s}r(B,"resolveExistingRequestPath");async function Y(t){try{let n=await B(t,y(t,"404.html"));return await $(n)}catch(n){if(n.code==="ENOENT")return;throw n}}r(Y,"readGeneratedNotFound");async function ae({root:t,port:n,server:i,liveReload:s=!1,basePath:f="/",configureServer:v}){let l=new Set,g=r(async(a,e)=>{if(a.method!=="GET"&&a.method!=="HEAD"){e.writeHead(405,{allow:"GET, HEAD"}),e.end("Method not allowed");return}let d=new URL(a.url??"/","http://127.0.0.1"),u=typeof f=="function"?f():f,R=`${u==="/"?"":u.replace(/\/$/,"")}/__canofold/events`;if(s&&d.pathname===R){e.writeHead(200,{"content-type":"text/event-stream","cache-control":"no-cache",connection:"keep-alive"}),e.write(`:connected
|
|
43
|
+
|
|
44
|
+
`),l.add(e);let o=r(()=>l.delete(e),"removeClient");a.once("close",o),e.once("close",o),e.once("error",o);return}let N=V(d.pathname,u),w,b=r(async()=>{e.statusCode=404;let o=await Y(w);if(o){e.setHeader("content-type",O[".html"]??"text/html; charset=utf-8"),s&&(o=Buffer.from(_(o.toString("utf8"),R))),e.end(a.method==="HEAD"?void 0:o);return}e.end(a.method==="HEAD"?void 0:"Not found")},"sendNotFound"),P=r(o=>{H("Static server error:",o),e.statusCode=500,e.end(a.method==="HEAD"?void 0:"Internal server error")},"sendInternalError");if(w=F(typeof t=="function"?t():t),N===void 0){try{await b()}catch(o){P(o)}return}let j;try{j=X(w,N)}catch{e.statusCode=403,e.end("Forbidden");return}try{let o,m;for(let C of j)try{let h=await B(w,C);m=await $(h),o=h;break}catch(h){if(h.message==="Forbidden"){e.statusCode=403,e.end("Forbidden");return}let M=h.code;if(M!=="ENOENT"&&M!=="EISDIR")throw h}if(!o||!m){await b();return}e.setHeader("content-type",G(o)),e.setHeader("cache-control","no-store"),s&&k(o)===".html"&&(m=Buffer.from(_(m.toString("utf8"),R))),e.end(a.method==="HEAD"?void 0:m)}catch(o){let m=o.code;if(m==="ENOENT"||m==="EISDIR")try{await b()}catch(C){P(C)}else P(o)}},"staticHandler"),c,p=i??L(),I=r((a,e)=>{let d=r(u=>{if(u){H("Mounted development server error:",u),e.statusCode=500,e.end("Internal server error");return}g(a,e)},"next");if(!c){d();return}try{c.middleware(a,e,d)}catch(u){d(u)}},"requestHandler");c=await v?.(p),p.on("request",I),await new Promise((a,e)=>{let d=r(u=>e(u),"onError");p.once("error",d),p.listen(n,"127.0.0.1",()=>{p.off("error",d),a()})});let x=p.address();if(!x||typeof x=="string")throw new Error("Failed to start server");let S=s?setInterval(()=>Q(l),q):void 0;return S?.unref(),{port:x.port,reload:r((a={protocol:1,type:"update",mode:"full",routes:[]})=>{E(l,D("update",JSON.stringify(a)))},"reload"),sendBuildError:r(a=>{E(l,D("build-error",a))},"sendBuildError"),sendBuildOk:r(()=>{E(l,D("build-ok"))},"sendBuildOk"),close:r(async()=>{S&&clearInterval(S),K(l),await c?.close?.(),p.off("request",I),await new Promise((a,e)=>p.close(d=>d?e(d):a()))},"close")}}r(ae,"startStaticServer");export{ae as a};
|
|
45
|
+
//# sourceMappingURL=chunk-GLAK57S4.js.map
|