@stacksjs/docs 0.75.659 → 0.75.660
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/screenshots.js +1 -1
- package/dist/stories.js +1 -1
- package/package.json +8 -8
package/dist/screenshots.js
CHANGED
|
@@ -109,7 +109,7 @@ ${a}::-webkit-search-cancel-button { visibility: hidden !important; }
|
|
|
109
109
|
return true
|
|
110
110
|
})()`,je=(e)=>e[0]===137&&e[1]===80?"image/png":"image/jpeg";async function te(e,o){if(!Number.isInteger(o.fps)||o.fps<1||o.fps>60)throw Error("Film frames per second must be an integer from 1 to 60");await e(Oe(o));let a=[],t,l={width:0,height:0},f=0,p=async(u)=>{let m=JSON.parse(String(await e(`window.__stacksFilm.drain(${u})`)));if(l={width:m.width,height:m.height},m.description)t=new Uint8Array(Buffer.from(m.description,"base64"));for(let[i,s,c]of m.chunks)a.push([i,s,new Uint8Array(Buffer.from(c,"base64"))])};return{frames:()=>f,async add(u,m){if(!Number.isInteger(m)||m<1)return;let i=u?`${JSON.stringify(Buffer.from(u).toString("base64"))}, ${JSON.stringify(je(u))}`:"null, null";if(await e(`window.__stacksFilm.add(${i}, ${m})`),f+=m,f%(o.fps*20)<m)await p(!1)},async addVideo(u,m=[]){for(let s of m)if(![s.x,s.y,s.size,s.start,s.end].every(Number.isFinite)||!/^#[0-9a-f]{6}$/i.test(s.color))throw Error("Invalid film mark");let i=JSON.parse(String(await e(`window.__stacksFilm.open(${JSON.stringify(u)})`)));for(let s=0;s<i.frames;s+=o.fps){let c=Math.min(o.fps,i.frames-s);await e(`window.__stacksFilm.copy(${s}, ${c}, ${JSON.stringify(m)})`),f+=c,await p(!1)}return i.seconds},async finish(){if(await p(!0),!a.length||!t)throw Error("The browser encoded no video");let u=new Pe,m=new Ee(u),i=m.addVideoTrack({codec:"h264",width:l.width,height:l.height,frameRate:o.fps,codecDescription:t});for(let[s,c,r]of a)await m.writePacket(i.id,{data:r,timestamp:c/1e6,duration:1/o.fps,isKeyframe:s===1});return await m.finalize(),u.buffer}}}import{createHash as Fe}from"crypto";import{lstat as Re,mkdir as Te,readFile as re,rename as se}from"fs/promises";import{dirname as Be,isAbsolute as Ne,join as W,relative as Ce,resolve as ie}from"path";var oe="<!-- Generated by buddy docs:screenshots. Edit config/screenshots.ts instead. -->",ne=(e)=>Fe("sha256").update(e).digest("hex"),N=(e)=>e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',"""),T=(e)=>N(e).replace(/[\r\n]+/g," ").replace(/([\\`*_[\]#|])/g,"\\$1");function ae(e,o,a,t){if(e){let l=e.secondsPerScreen??2;if(!Number.isFinite(l)||l<0.2||l>30)throw Error("film.secondsPerScreen must be between 0.2 and 30");if(!Number.isInteger(e.fps??12)||(e.fps??12)<1||(e.fps??12)>60)throw Error("film.fps must be an integer from 1 to 60");for(let f of e.viewports??[])if(!t.some((p)=>p.name===f))throw Error(`Unknown film viewport: ${f}`)}if(o){let l=ie(a,o.page);if(Ne(o.page)||Ce(a,l).startsWith("..")||!o.page.endsWith(".md"))throw Error("docs.page must be a Markdown file inside the project");if(!/^\/[\w./-]*$/.test(o.base)||o.base.includes(".."))throw Error("docs.base must be a site path such as /screens")}}async function q(e,o,a,t,l=process.platform==="darwin"?"webkit":"chrome"){let f=[],p=t.secondsPerScreen??2,u=t.fps??12,m=Math.max(1,Math.round(p*u)),i=H(l),s=ee();try{for(let c of a){if(t.viewports?.length&&!t.viewports.includes(c.name))continue;let r=o.filter((y)=>y.status==="captured"&&y.file&&y.viewport.name===c.name);if(!r.length)continue;let n,d;try{d=await i.view(320,240);let y=d;await y.navigate(s.url);let k=await te((b)=>y.evaluate(b),{fps:u,width:c.width,height:c.height});for(let b of r)await k.add(new Uint8Array(await re(W(e,b.file))),m);n=await k.finish()}catch(y){throw Error(`The ${c.name} screens could not be filmed: ${y instanceof Error?y.message.slice(0,400):"the browser failed"}`)}finally{d?.close()}let h=`film-${c.name}.mp4`;await Bun.write(W(e,`${h}.tmp`),n),await se(W(e,`${h}.tmp`),W(e,h)),f.push({viewport:c.name,file:h,sha256:ne(n),screens:r.length,seconds:r.length*m/u})}return f}finally{try{await i.close()}finally{s.stop()}}}function Ue(e,o){let a=o.base.replace(/\/+$/,""),t=o.title??"Screens",l=e.results.filter((i)=>i.status==="captured"&&i.file),f=["---",`title: ${JSON.stringify(t)}`,`description: ${JSON.stringify(o.description??"Every screen of the application, captured automatically from its views.")}`,"---","",oe,"",`# ${T(t)}`,"",`${new Set(l.map((i)=>i.id)).size} of ${e.inventory.length} screens, captured automatically from the application's views with @stacksjs/docs ${e.generatorVersion}. A new view appears here after the next capture.`,""];for(let i of e.films??[]){let s=l.find((c)=>c.viewport.name===i.viewport);f.push(`## Walkthrough video (${T(i.viewport)})`,"",`<video controls playsinline preload="none" src="${N(`${a}/${i.file}`)}"${s?` poster="${N(`${a}/${s.file}`)}"`:""} style="width:100%;max-width:${s&&s.viewport.width<600?s.viewport.width:1100}px;height:auto"></video>`,"",`${i.screens} screens in ${Math.round(i.seconds)} seconds. [Download the video](${a}/${i.file}).`,"")}let p=(i)=>i.split("/").filter(Boolean)[0]?.replace(/^[[:].*/,"profiles")??"home",u=new Map;for(let i of e.inventory)u.set(p(i.path),[...u.get(p(i.path))??[],i]);let m=[];for(let[i,s]of[...u].sort(([c],[r])=>c.localeCompare(r))){let c=[];for(let r of s){let n=l.filter((d)=>d.id===r.id);if(!n.length){let d=e.results.find((h)=>h.id===r.id);m.push(`- ${T(r.title)} (\`${r.path}\`): ${r.skip?T(r.skip):d?"the last capture failed.":"not captured yet."}`);continue}c.push(`### ${T(r.title)}`,"",T(n[0].description),"",...n[0].reason?[T(n[0].reason),""]:[],`Address: \`${r.path}\``,"");for(let d of n)c.push("<figure>",` <img src="${N(`${a}/${d.file}`)}" alt="${N(`${d.title}, ${d.viewport.name}`)}" width="${d.viewport.width}" height="${d.viewport.height}" loading="lazy" style="display:block;width:100%;max-width:${d.viewport.width}px;height:auto">`,` <figcaption>${N(d.viewport.name)}, ${d.viewport.width} by ${d.viewport.height}${d.profile==="default"?"":`, signed in as ${N(d.profile)}`}</figcaption>`,"</figure>","")}if(c.length)f.push(`## ${T(i[0].toUpperCase()+i.slice(1).replace(/[-_]+/g," "))}`,"",...c)}if(m.length)f.push("## Not pictured","","These screens are part of the application and have no picture here.","",...m,"");return`${f.join(`
|
|
111
111
|
`).trimEnd()}
|
|
112
|
-
`}async function I(e,o,a){let t=ie(e,a.page);try{if((await Re(t)).isSymbolicLink()||!(await re(t,"utf8")).includes(oe))throw Error(`Refusing to replace a hand-written page: ${a.page}`)}catch(f){if(f.code!=="ENOENT")throw f}let l=Ue(o,a);return await Te(Be(t),{recursive:!0}),await Bun.write(`${t}.tmp`,l),await se(`${t}.tmp`,t),{path:a.page,sha256:ne(l)}}import{createRouter as Ae}from"@stacksjs/stx";import{readFileSync as De}from"fs";import{relative as Ve,resolve as He}from"path";var ce=(e)=>e.replace(/[-_]+/g," ").replace(/\s+/g," ").trim(),Le=(e)=>e?e[0].toUpperCase()+e.slice(1):e;function Je(e){try{return De(e,"utf8")}catch{return""}}function We(e,o){let a=e.match(/<title>([^<{@]+)<\/title>/i)?.[1]?.trim();if(a)return a;let t=o.split("/").filter(Boolean).map((l)=>l.startsWith("[")?`by ${ce(l.slice(1,-1).replace(/^\.\.\./,""))}`:ce(l));return t.length?Le(t.join(" / ")):"Home"}function le(e={}){let o=He(e.root??process.cwd()),a=[],t=new Set;for(let l of e.directories??["resources/views"])for(let f of Ae(o,{pagesDir:l,emit:!1})){let p=f.pattern.replace(/\*(\w*)/g,(c,r)=>`[...${r||"path"}]`).replace(/:(\w+)/g,"[$1]"),u=p.split("/").filter(Boolean).map((c)=>c.replace(/[^a-z0-9]+/gi,"-").replace(/^-|-$/g,"")).filter(Boolean).join("-").toLowerCase()||"index",m=u;for(let c=2;t.has(m);c++)m=`${u}-${c}`;t.add(m);let i=Je(f.filePath),s=i.match(/@(?:extends|layout)\(\s*['"]([^'"]+)['"]/)?.[1];a.push({id:m,route:p,source:Ve(o,f.filePath).replaceAll("\\","/"),group:p.split("/").filter(Boolean)[0]?.replace(/^\[.*\]$/,"profile")??"home",params:[...f.params],dynamic:f.isDynamic,title:We(i,p),...s?{layout:s}:{},text:i})}return a.sort((l,f)=>l.route<f.route?-1:l.route>f.route?1:0)}function _e(e={}){let o=[],a=new Set;for(let t of le(e)){a.add(t.route);let l=[e.each?.(t),e.routes?.[t.route]],f={id:t.id,title:t.title,path:t.route,description:`The ${t.title} screen, served at ${t.route}.`,waitFor:"body",...e.defaults,sources:[t.source]};for(let p of l){if(p===void 0)continue;if(p===!1||typeof p==="string"){f.skip=p||"Left out of the screen documentation on purpose.";continue}Object.assign(f,p)}if(t.dynamic&&typeof f.path==="string"&&f.path===t.route&&!f.model&&!f.skip){if(e.strict)throw Error(`Dynamic view needs a concrete path or model: ${t.route} (${t.source})`);f.skip=`Needs a seeded example: give ${t.route} a concrete path, fixture resolver or model.`}if(typeof f.path==="function"&&!f.route)f.route=t.route;o.push(f)}for(let t of Object.keys(e.routes??{}))if(!a.has(t))throw Error(`Screenshot rule for a view that does not exist: ${t}`);return[...o,...e.extra??[]]}import{spawnOwnedProcess as Xe}from"@stacksjs/cli/owned-process";var A="0.75.
|
|
112
|
+
`}async function I(e,o,a){let t=ie(e,a.page);try{if((await Re(t)).isSymbolicLink()||!(await re(t,"utf8")).includes(oe))throw Error(`Refusing to replace a hand-written page: ${a.page}`)}catch(f){if(f.code!=="ENOENT")throw f}let l=Ue(o,a);return await Te(Be(t),{recursive:!0}),await Bun.write(`${t}.tmp`,l),await se(`${t}.tmp`,t),{path:a.page,sha256:ne(l)}}import{createRouter as Ae}from"@stacksjs/stx";import{readFileSync as De}from"fs";import{relative as Ve,resolve as He}from"path";var ce=(e)=>e.replace(/[-_]+/g," ").replace(/\s+/g," ").trim(),Le=(e)=>e?e[0].toUpperCase()+e.slice(1):e;function Je(e){try{return De(e,"utf8")}catch{return""}}function We(e,o){let a=e.match(/<title>([^<{@]+)<\/title>/i)?.[1]?.trim();if(a)return a;let t=o.split("/").filter(Boolean).map((l)=>l.startsWith("[")?`by ${ce(l.slice(1,-1).replace(/^\.\.\./,""))}`:ce(l));return t.length?Le(t.join(" / ")):"Home"}function le(e={}){let o=He(e.root??process.cwd()),a=[],t=new Set;for(let l of e.directories??["resources/views"])for(let f of Ae(o,{pagesDir:l,emit:!1})){let p=f.pattern.replace(/\*(\w*)/g,(c,r)=>`[...${r||"path"}]`).replace(/:(\w+)/g,"[$1]"),u=p.split("/").filter(Boolean).map((c)=>c.replace(/[^a-z0-9]+/gi,"-").replace(/^-|-$/g,"")).filter(Boolean).join("-").toLowerCase()||"index",m=u;for(let c=2;t.has(m);c++)m=`${u}-${c}`;t.add(m);let i=Je(f.filePath),s=i.match(/@(?:extends|layout)\(\s*['"]([^'"]+)['"]/)?.[1];a.push({id:m,route:p,source:Ve(o,f.filePath).replaceAll("\\","/"),group:p.split("/").filter(Boolean)[0]?.replace(/^\[.*\]$/,"profile")??"home",params:[...f.params],dynamic:f.isDynamic,title:We(i,p),...s?{layout:s}:{},text:i})}return a.sort((l,f)=>l.route<f.route?-1:l.route>f.route?1:0)}function _e(e={}){let o=[],a=new Set;for(let t of le(e)){a.add(t.route);let l=[e.each?.(t),e.routes?.[t.route]],f={id:t.id,title:t.title,path:t.route,description:`The ${t.title} screen, served at ${t.route}.`,waitFor:"body",...e.defaults,sources:[t.source]};for(let p of l){if(p===void 0)continue;if(p===!1||typeof p==="string"){f.skip=p||"Left out of the screen documentation on purpose.";continue}Object.assign(f,p)}if(t.dynamic&&typeof f.path==="string"&&f.path===t.route&&!f.model&&!f.skip){if(e.strict)throw Error(`Dynamic view needs a concrete path or model: ${t.route} (${t.source})`);f.skip=`Needs a seeded example: give ${t.route} a concrete path, fixture resolver or model.`}if(typeof f.path==="function"&&!f.route)f.route=t.route;o.push(f)}for(let t of Object.keys(e.routes??{}))if(!a.has(t))throw Error(`Screenshot rule for a view that does not exist: ${t}`);return[...o,...e.extra??[]]}import{spawnOwnedProcess as Xe}from"@stacksjs/cli/owned-process";var A="0.75.660";var Nt=(e)=>e,F=[{name:"desktop",width:1440,height:900},{name:"mobile",width:390,height:844}],V=(e)=>Ie("sha256").update(e).digest("hex"),K=(e)=>/^[a-z0-9][a-z0-9._-]*$/i.test(e)&&!e.endsWith(".")&&!/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(e),de=(e)=>{let o=new URL(e);return o.origin+o.pathname};async function he(e,o=process.cwd()){let a=new URL(e.baseUrl);if(!["http:","https:"].includes(a.protocol)||a.username||a.password||a.search||a.hash)throw Error("baseUrl must be an http(s) URL without credentials, query or fragment");if(!e.outDir||!e.pages.length)throw Error("outDir and at least one page are required");if(e.timeoutMs!==void 0&&(!Number.isFinite(e.timeoutMs)||e.timeoutMs<100||e.timeoutMs>120000))throw Error("timeoutMs must be between 100 and 120000");if(e.backend&&!["webkit","chrome"].includes(e.backend))throw Error("backend must be webkit or chrome");if(e.requireHttpStatus!==void 0&&typeof e.requireHttpStatus!=="boolean")throw Error("requireHttpStatus must be a boolean");let t=Object.keys(e.profiles??{default:{}});if(!t.length||t.some((i)=>!K(i)))throw Error("Profile names must be safe filenames");let l=new Set,f=new Set;for(let i of e.pages){if(!K(i.id)||l.has(i.id))throw Error(`Duplicate or invalid screen id: ${i.id}`);if(l.add(i.id),i.expectedStatus!==void 0&&(!Number.isInteger(i.expectedStatus)||i.expectedStatus<100||i.expectedStatus>599))throw Error(`Invalid expected HTTP status for ${i.id}`);if(!i.title.trim()||!i.description.trim()||!i.waitFor.trim())throw Error(`Screen ${i.id} needs title, description and waitFor`);if(typeof i.path!=="string"&&(typeof i.path!=="function"||!i.route))throw Error(`Screen ${i.id} needs a route pattern for its path resolver`);let s=new URL(typeof i.path==="string"?i.path:i.route,a);if(s.origin!==a.origin||s.username||s.password)throw Error(`Screen ${i.id} must stay on baseUrl's origin`);if(i.profiles?.some((c)=>!t.includes(c))||i.profiles?.length===0)throw Error(`Unknown or empty profiles for ${i.id}`);for(let c of i.sources??[]){let r=S(o,c);if(B(o,r).startsWith("..")||ue(c))throw Error(`Source must be inside the project: ${c}`);await M(r),f.add(B(o,r).replaceAll("\\","/"))}}let p=new Set;for(let i of e.viewports??F){if(!K(i.name)||p.has(i.name)||![i.width,i.height].every((s)=>Number.isInteger(s)&&s>=200&&s<=7680))throw Error("Viewports need unique safe names and integer dimensions from 200 to 7680");p.add(i.name)}if(!p.size)throw Error("At least one viewport is required");for(let i of e.pages)if(i.viewports!==void 0&&(!i.viewports.length||i.viewports.some((s)=>!p.has(s))))throw Error(`Unknown or empty viewports for ${i.id}`);for(let i of e.inputs??[])await M(S(o,i));ae(e.film===!0?{}:e.film,e.docs,o,e.viewports??F);let u=[],m=new Set;for(let i of e.coverage?.directories??[]){let s=S(o,i);if(B(o,s).startsWith(".."))throw Error("Coverage directories must be inside the project");if(!(await Ke(s)).isDirectory())throw Error(`Missing coverage directory: ${i}`);let c=0;for await(let r of new Bun.Glob("**/*.stx").scan({cwd:s,onlyFiles:!0})){c++;let n=B(o,g(s,r)).replaceAll("\\","/");if(m.add(n),!f.has(n)&&!e.coverage?.exclude?.[n]?.trim())u.push(n)}if(!c)throw Error(`No .stx screens found in ${i}`)}for(let[i,s]of Object.entries(e.coverage?.exclude??{}))if(!s.trim()||!m.has(i))throw Error(`Stale or unexplained coverage exclusion: ${i}`);if(u.length)throw Error(`Undocumented screens:
|
|
113
113
|
${u.sort().join(`
|
|
114
114
|
`)}`)}async function X(e){let o=(await import(Qe(e).href)).default;if(!o||typeof o!=="object")throw Error("Screenshot configuration must have a default export");return o}async function Ye(e,o){let a=Date.now()+o;while(!await e()){if(Date.now()>=a)throw Error("The screen did not become ready before its deadline");await Bun.sleep(100)}}function me(e,o){let a=e instanceof Error?e.message:"Screenshot capture failed";for(let t of o.redactEnv??[]){let l=process.env[t];if(l)a=a.replaceAll(l,"[redacted]")}return a.slice(0,1000)}async function Ze(e,o,a){let t=await X(e),l=S(a.root),f=S(l,a.outDir??t.outDir),p=[],u=await J(l,t.models),m=H(t.backend??(process.platform==="darwin"?"webkit":"chrome"));try{let i={...t.fixtures,...await t.data?.prepare(u)},s=t.timeoutMs??30000;for(let c of t.viewports??F){if(a.viewports?.length&&!a.viewports.includes(c.name))continue;for(let r of t.pages){if(a.only?.length&&!a.only.includes(r.id))continue;if(!(r.profiles??Object.keys(t.profiles??{default:{}})).includes(o))continue;if(r.viewports&&!r.viewports.includes(c.name))continue;let n={id:r.id,profile:o,viewport:c,title:r.title,description:r.description,...r.reason?{reason:r.reason}:{},path:new URL(typeof r.path==="string"?r.path:r.route,t.baseUrl).pathname,status:"failed"};if(p.push(n),r.skip){n.status="skipped",n.error=r.skip,process.send?.({type:"screenshot-result",result:n});continue}let d="starting the browser",h,y;try{h=await m.view(c.width,c.height),await Promise.race([(async()=>{let k=typeof r.path==="function"?await r.path({fixtures:i,models:u,profile:o}):_(r.path,r.model,i,u),b=new URL(k,t.baseUrl);if(b.origin!==new URL(t.baseUrl).origin||b.username||b.password)throw Error("Resolved screenshot path must stay on the configured origin");let O={...r,path:k},j={view:h,baseUrl:t.baseUrl,profile:o,viewport:c,page:O};n.path=b.pathname,d="preparing the review profile",await t.profiles?.[o]?.prepare?.(j),d="opening the screen",await h.navigate(new URL(O.path,t.baseUrl).href),d="checking the document HTTP status";let x=Number(await h.evaluate("performance.getEntriesByType('navigation')[0]?.responseStatus || 0"));if(Number.isInteger(x)&&x>=100&&x<=599)j.httpStatus=n.httpStatus=x;if(!j.httpStatus&&(t.requireHttpStatus||r.expectedStatus!==void 0))throw Error("The browser did not expose a document HTTP status; choose the chrome backend for HTTP-verified captures");if(r.expectedStatus!==void 0?j.httpStatus!==r.expectedStatus:x>=400)throw Error(`The screen returned HTTP ${x}${r.expectedStatus!==void 0?` instead of ${r.expectedStatus}`:"; check its route, access and fixture"}`);d="preparing the screen state",await r.prepare?.(j),d="waiting for screen readiness",await Ye(async()=>Boolean(await h.evaluate(`Boolean(document.querySelector(${JSON.stringify(r.waitFor)}))`))&&(!r.ready||await r.ready(j)),s);let w=String(await h.evaluate("location.href"));if(de(w)!==de(new URL(O.path,t.baseUrl).href))throw Error("The screen redirected to a different route; check its login and fixture");if(d="loading fonts and visible images",await h.evaluate(`(async () => {
|
|
115
115
|
const style = document.createElement('style'); style.textContent = '*{animation:none!important;transition:none!important;scroll-behavior:auto!important;caret-color:transparent!important}'; document.head.append(style);
|
package/dist/stories.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{createHash as tt,randomUUID as ot}from"crypto";import{createReadStream as nt}from"fs";import{copyFile as at,lstat as _,mkdir as T,open as ct,readFile as S,realpath as dt,rename as Y,rm as ft,writeFile as R}from"fs/promises";import{basename as lt,dirname as W,isAbsolute as et,join as a,relative as P,resolve as b,sep as ut}from"path";import{pathToFileURL as pt}from"url";var X="0.75.
|
|
2
|
+
import{createHash as tt,randomUUID as ot}from"crypto";import{createReadStream as nt}from"fs";import{copyFile as at,lstat as _,mkdir as T,open as ct,readFile as S,realpath as dt,rename as Y,rm as ft,writeFile as R}from"fs/promises";import{basename as lt,dirname as W,isAbsolute as et,join as a,relative as P,resolve as b,sep as ut}from"path";import{pathToFileURL as pt}from"url";var X="0.75.660";function xt(t){return t}function Et(t){return t}var C=`stacks-story-recordings-v1
|
|
3
3
|
`,z="<!-- Generated by buddy docs:stories. -->",I=(t)=>tt("sha256").update(t).digest("hex"),Z=(t)=>typeof t==="string"&&/^[a-z0-9][a-z0-9-]{0,79}$/.test(t);function v(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replace(/[\r\n]/g," ").replace(/([\\`*_[\]#|])/g,"\\$1")}async function J(t){try{return await _(t),!0}catch(i){if(i.code==="ENOENT")return!1;throw i}}async function g(t,i=t){let n=b(t);while(!0){if(await J(n)){if((await _(n)).isSymbolicLink())throw Error(`Story output cannot traverse a symbolic link: ${n}`)}if(n===b(i))return;let e=W(n);if(e===n)return;n=e}}async function L(t,i){await g(i,t);let n=await _(i);if(!n.isFile()||n.size===0)throw Error(`Missing or empty story artifact: ${i}`);let e=tt("sha256"),c=0;for await(let u of nt(i))e.update(u),c+=u.length;return{path:P(t,i).split(ut).join("/"),sha256:e.digest("hex"),bytes:c}}function B(t,i){let n=b(t,i.path);if(!i.path||et(i.path)||P(t,n).startsWith(".."))throw Error("Story artifact escaped its output directory");return n}async function ht(t){if(!t||!Array.isArray(t.stories)||!t.stories.length)throw Error("Story configuration needs at least one story");let i=new Set,n=(e,c,u,r)=>{if(!Number.isInteger(e)||e<c||e>u)throw Error(`Invalid story ${r}`)};n(t.fps??12,1,60,"fps (1 to 60)"),n(t.holdMs??700,0,30000,"holdMs (0 to 30000)"),n(t.timeoutMs??120000,100,1800000,"timeoutMs (100 to 1800000)");for(let e of t.stories){if(!Z(e.id)||i.has(e.id)||!e.title?.trim())throw Error(`Invalid or duplicate story id/title: ${e.id}`);if(i.add(e.id),!["browser","ios","android"].includes(e.driver?.platform)||typeof e.driver.open!=="function")throw Error(`Invalid driver for story ${e.id}`);if(!Array.isArray(e.scenes)||!e.scenes.length)throw Error(`Story ${e.id} has no scenes`);let c=new Set;for(let u of e.scenes){if(!Z(u.id)||c.has(u.id)||!u.title?.trim()||typeof u.run!=="function")throw Error(`Invalid or duplicate scene in ${e.id}: ${u.id}`);c.add(u.id),n(u.holdMs??t.holdMs??700,0,30000,"scene holdMs"),n(u.timeoutMs??t.timeoutMs??120000,100,1800000,"scene timeoutMs")}}}function wt(t,i){let n=[z,`# ${v(t.title)}`,"",t.description?v(t.description):"","",`Platform: ${t.platform}. Result: **${t.status}**.`,""];if(t.video)n.push(`<video controls playsinline preload="metadata" src="${i}${t.video.path}" poster="${t.scenes.find((e)=>e.screenshot)?.screenshot?i+t.scenes.find((e)=>e.screenshot).screenshot.path:""}"></video>`,"",`[Download video](${i}${t.video.path})`,"");for(let e of t.scenes)if(n.push(`## ${v(e.title)}`,"",`Result: **${e.status}**.${e.startedMs===void 0?"":` Starts at ${(e.startedMs/1000).toFixed(1)}s.`}`,"",e.description?v(e.description):"",""),e.screenshot)n.push(``,"");else n.push("No screenshot was captured for this scene.","");return`${n.join(`
|
|
4
4
|
`).trimEnd()}
|
|
5
5
|
`}async function $t(t={}){if(t.list&&t.check)throw Error("Choose --list or --check");let i=await dt(b(t.root??process.cwd())),n=b(i,t.config??"config/stories.ts"),e=await S(n),c=(await import(`${pt(n).href}?story=${I(e)}`)).default;await ht(c);let u=[X,I(e),I(JSON.stringify(c,(s,o)=>typeof o==="function"?o.toString():o))];for(let s of[...c.inputs??[]].sort())u.push(`${s}:${I(await S(b(i,s)))}`);let r=b(i,t.outDir??c.outDir??"docs/stories"),l=c.publishDir===!1?void 0:b(i,c.publishDir??a(W(r),"public",lt(r)));if(l&&(l===r||!P(r,l).startsWith("..")||!P(l,r).startsWith("..")))throw Error("Published media must have a separate directory outside the story output");if(r===i||P(r,i)===""||!P(r,i).startsWith("..")&&!et(P(r,i)))throw Error("Story output must not contain the project root");let p={version:1,configHash:I(u.join(`
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/docs",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.660",
|
|
6
6
|
"description": "The Stacks way to document.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -58,19 +58,19 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@stacksjs/bunpress": "^0.2.25",
|
|
61
|
-
"@stacksjs/cli": "0.75.
|
|
62
|
-
"@stacksjs/config": "0.75.
|
|
63
|
-
"@stacksjs/path": "0.75.
|
|
64
|
-
"@stacksjs/orm": "0.75.
|
|
61
|
+
"@stacksjs/cli": "0.75.660",
|
|
62
|
+
"@stacksjs/config": "0.75.660",
|
|
63
|
+
"@stacksjs/path": "0.75.660",
|
|
64
|
+
"@stacksjs/orm": "0.75.660",
|
|
65
65
|
"@stacksjs/stx": "^0.2.908",
|
|
66
|
-
"@stacksjs/testing": "0.75.
|
|
66
|
+
"@stacksjs/testing": "0.75.660",
|
|
67
67
|
"@ts-videos/mp4": "^0.1.2",
|
|
68
68
|
"craft-native": ">=0.0.499",
|
|
69
69
|
"ts-videos": "^0.1.2"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@stacksjs/alias": "0.75.
|
|
73
|
-
"@stacksjs/server": "0.75.
|
|
72
|
+
"@stacksjs/alias": "0.75.660",
|
|
73
|
+
"@stacksjs/server": "0.75.660",
|
|
74
74
|
"better-dx": "^0.2.39"
|
|
75
75
|
}
|
|
76
76
|
}
|