@three-blocks/devtools 1.0.0-alpha.193.g4eb273dec3a7 → 1.0.0-alpha.208.g664cb7c258f9

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.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import {d as d$2,b as b$2,c as c$3,g as g$2}from'./chunk-76WRV5MZ.js';import {g as g$1}from'./chunk-JMS5NTP7.js';import {a as a$3,c as c$2,b,d as d$1}from'./chunk-G65XQ3DF.js';import {a as a$1,c,b as b$1}from'./chunk-ZDNZCQUQ.js';import {j,d,i,a as a$2,c as c$1}from'./chunk-5L2VS3BN.js';import {a}from'./chunk-HOZDD6PW.js';import {realpath}from'fs/promises';import h from'path';var te=".three-blocks/runtime/status.json",re=256*1024,H="three-blocks browser smoke",se=["three-blocks.json","three-blocks.shaders.json","three-blocks.text.ts"];function Q(e){return "kind"in e&&e.kind==="adopted"}a(Q,"isAdoptedProjectStatus");async function O(e,t,r,s){let n=await j(e,t,r,s);return JSON.parse(n.data.toString("utf8"))}a(O,"readJsonWithin");var ne=["starting","worker ready","assets ready","compiled","first frame","updating","error"],ae=["ready","generating","fallback","missing","invalid"],oe=["WebGPU","WebGL"],ie=["OffscreenCanvas","MainThread"],de=/^[0-9A-Za-z][0-9A-Za-z._-]{0,63}$/,X=16,K=1e9;function g(e,t,r,s=[]){if(!a$1(e))throw new Error(`${t} must be an object.`);let n=new Set([...r,...s]);for(let o of r)if(!Object.hasOwn(e,o))throw new Error(`${t}.${o} is required.`);for(let o of Object.keys(e))if(!n.has(o))throw new Error(`${t}.${o} is not supported by schema v1.`);return e}a(g,"exactRecord");function A(e,t,r){if(typeof e!="string"||!t.includes(e))throw new Error(`${r} has an unsupported value.`);return e}a(A,"enumValue");function p(e,t){if(typeof e!="boolean")throw new Error(`${t} must be a boolean.`);return e}a(p,"booleanValue");function Y(e,t){return e===null?null:p(e,t)}a(Y,"nullableBoolean");function E(e,t){if(typeof e!="number"||!Number.isSafeInteger(e)||e<0||e>K)throw new Error(`${t} must be a non-negative integer no greater than ${K}.`);return e}a(E,"boundedCounter");function ce(e){if(typeof e!="string"||e.length>32)throw new Error("Runtime status receipt observedAt must be a bounded ISO timestamp.");let t=Date.parse(e);if(!Number.isFinite(t)||new Date(t).toISOString()!==e)throw new Error("Runtime status receipt observedAt must be an exact ISO timestamp.");return e}a(ce,"observedTimestamp");function ue(e){if(e===null)return null;if(typeof e!="string"||e.length===0||e.length>2048||/[\u0000-\u001f\u007f]/u.test(e))throw new Error("Runtime status receipt error must be null or one bounded display-safe line.");return e}a(ue,"receiptError");function le(e){if(!Array.isArray(e)||e.length>X)throw new Error(`Runtime status receipt assets.codecs must contain at most ${X} entries.`);let t=e.map((r,s)=>{let n=g(r,`Runtime status receipt assets.codecs[${s}]`,["name","available","decoded"]);if(typeof n.name!="string"||!de.test(n.name))throw new Error(`Runtime status receipt assets.codecs[${s}].name is invalid.`);let o=p(n.available,`Runtime status receipt assets.codecs[${s}].available`),a=p(n.decoded,`Runtime status receipt assets.codecs[${s}].decoded`);if(a&&!o)throw new Error(`Runtime status receipt codec ${JSON.stringify(n.name)} cannot be decoded when unavailable.`);return {name:n.name,available:o,decoded:a}});if(new Set(t.map(r=>r.name)).size!==t.length)throw new Error("Runtime status receipt assets.codecs must have unique names.");return t}a(le,"parseRuntimeCodecs");function me(e){if(e.assetsReady&&!e.workerReady)throw new Error("Runtime lifecycle assetsReady requires workerReady.");if(e.compiled&&!e.assetsReady)throw new Error("Runtime lifecycle compiled requires assetsReady.");if(e.firstFrame&&!e.compiled)throw new Error("Runtime lifecycle firstFrame requires compiled.");let t=e.state==="starting"?[false,false,false,false]:e.state==="worker ready"?[true,false,false,false]:e.state==="assets ready"?[true,true,false,false]:e.state==="compiled"?[true,true,true,false]:e.state==="first frame"||e.state==="updating"?[true,true,true,true]:null;if(t!==null&&![e.workerReady,e.assetsReady,e.compiled,e.firstFrame].every((r,s)=>r===t[s]))throw new Error(`Runtime lifecycle flags do not match state ${JSON.stringify(e.state)}.`)}a(me,"validateLifecycle");function pe(e){let t=g(e,"Runtime status receipt",["schemaVersion","observedAt","worker","assets","hmr","stats","lifecycle","shaders","error"],["text"]);if(t.schemaVersion!==1)throw new Error("Runtime status receipt must use schemaVersion 1.");let r=g(t.worker,"Runtime status receipt worker",["backend","renderer","protocolVersion"]);if(r.protocolVersion!==1)throw new Error("Runtime status receipt worker.protocolVersion must be 1.");let s=g(t.assets,"Runtime status receipt assets",["codecs","resources"]),n=g(t.hmr,"Runtime status receipt hmr",["capabilities","outcome"]),o=g(n.capabilities,"Runtime status receipt hmr.capabilities",["scene","component","assetManifest","workerRestart"]),a=g(n.outcome,"Runtime status receipt hmr.outcome",["attempted","succeeded","rollbackPreserved","workerRestarted"]),d=p(a.attempted,"Runtime status receipt hmr.outcome.attempted"),l=Y(a.succeeded,"Runtime status receipt hmr.outcome.succeeded"),m=Y(a.rollbackPreserved,"Runtime status receipt hmr.outcome.rollbackPreserved"),y=p(a.workerRestarted,"Runtime status receipt hmr.outcome.workerRestarted");if(d?l===null||m===null:l!==null||m!==null||y)throw new Error("Runtime status receipt HMR outcome fields are inconsistent with attempted.");let k={scene:p(o.scene,"Runtime status receipt hmr.capabilities.scene"),component:p(o.component,"Runtime status receipt hmr.capabilities.component"),assetManifest:p(o.assetManifest,"Runtime status receipt hmr.capabilities.assetManifest"),workerRestart:p(o.workerRestart,"Runtime status receipt hmr.capabilities.workerRestart")};if(d&&!k.scene)throw new Error("Runtime status receipt cannot attempt HMR without the scene capability.");if(y&&!k.workerRestart)throw new Error("Runtime status receipt cannot restart a worker without the workerRestart capability.");let x=g(t.stats,"Runtime status receipt stats",["snapshots","textures","workerProfiler","mainPanels"]),R=g(t.lifecycle,"Runtime status receipt lifecycle",["state","workerReady","assetsReady","compiled","firstFrame"]),S={state:A(R.state,ne,"Runtime status receipt lifecycle.state"),workerReady:p(R.workerReady,"Runtime status receipt lifecycle.workerReady"),assetsReady:p(R.assetsReady,"Runtime status receipt lifecycle.assetsReady"),compiled:p(R.compiled,"Runtime status receipt lifecycle.compiled"),firstFrame:p(R.firstFrame,"Runtime status receipt lifecycle.firstFrame")};me(S);let V=g(t.shaders,"Runtime status receipt shaders",["mode","pipelines"]),P=A(V.mode,["precompiled","live"],"Runtime status receipt shaders.mode"),T=E(V.pipelines,"Runtime status receipt shaders.pipelines");if(P==="precompiled"&&T===0)throw new Error("A precompiled runtime receipt must observe at least one shader pipeline.");let f;if(t.text!==void 0){let I=g(t.text,"Runtime status receipt text",["state","atlases","glyphs","requiredGlyphs"]);if(f={state:A(I.state,ae,"Runtime status receipt text.state"),atlases:E(I.atlases,"Runtime status receipt text.atlases"),glyphs:E(I.glyphs,"Runtime status receipt text.glyphs"),requiredGlyphs:E(I.requiredGlyphs,"Runtime status receipt text.requiredGlyphs")},f.state==="ready"&&(f.atlases===0||f.requiredGlyphs===0||f.glyphs<f.requiredGlyphs))throw new Error("A ready text receipt must cover a non-empty required glyph set with at least one atlas.")}let b=ue(t.error);if(S.state==="error"?b===null:b!==null)throw new Error("Runtime status receipt error must be present only when lifecycle.state is error.");return {schemaVersion:1,observedAt:ce(t.observedAt),worker:{backend:A(r.backend,ie,"Runtime status receipt worker.backend"),renderer:A(r.renderer,oe,"Runtime status receipt worker.renderer"),protocolVersion:1},assets:{codecs:le(s.codecs),resources:E(s.resources,"Runtime status receipt assets.resources")},hmr:{capabilities:k,outcome:{attempted:d,succeeded:l,rollbackPreserved:m,workerRestarted:y}},stats:{snapshots:E(x.snapshots,"Runtime status receipt stats.snapshots"),textures:E(x.textures,"Runtime status receipt stats.textures"),workerProfiler:p(x.workerProfiler,"Runtime status receipt stats.workerProfiler"),mainPanels:p(x.mainPanels,"Runtime status receipt stats.mainPanels")},lifecycle:S,shaders:{mode:P,pipelines:T},...f===void 0?{}:{text:f},error:b}}a(pe,"parseRuntimeStatusReceipt");function he(e,t){return e.render===t.render&&e.vertex===t.vertex&&e.fragment===t.fragment&&e.compute===t.compute}a(he,"sameCoverage");async function ee(e=process.cwd()){let t=h.resolve(e);for(;;){if((await Promise.all(se.map(s=>d(h.join(t,s))))).some(Boolean))return realpath(t);let r=h.dirname(t);if(r===t)return realpath(h.resolve(e));t=r;}}a(ee,"findProjectRoot");async function fe(e,t){let r=t.template,s=h.join(e,".three-blocks","shaders"),n=h.join(s,"meta.json");if(!await d(s)||!await d(n))return {state:"missing",scene:r,reason:t.artifacts?.shaders==="pending"?"The selected template has no verified shader capture yet.":".three-blocks/shaders/meta.json is absent."};try{let o=await i(e,s,"Shader artifact directory"),a=c(await O(o,n,a$2.receipt,"Shader receipt")),d=a.scenes[r];if(d===void 0)return {state:"invalid",scene:r,reason:`Shader receipt has no "${r}" scene.`};let l=await j(o,h.join(o,d.artifact),a$2.manifest,"Shader manifest");if(c$1(l.data)!==d.artifactHash)return {state:"invalid",scene:r,reason:"The selected shader manifest checksum does not match its receipt."};let m=a$3(l.data.toString("utf8"),l.path,r);if(!he(m,d.coverage))return {state:"invalid",scene:r,reason:"Shader receipt coverage does not match the manifest entries.",coverage:m};let{three:y,threeBlocks:k,threeBlocksShaderClosure:x}=await c$2(e);if(a.runtime.three!==y||t.runtime.three!==y||a.runtime.threeBlocks!==k||t.runtime.threeBlocks!==k)return {state:"stale",scene:r,reason:`Installed runtime versions (${y}, ${k}) do not match the metadata and shader receipt.`,coverage:m};if(a.runtime.threeBlocksShaderClosure!==x)return {state:"stale",scene:r,reason:"The installed three-blocks/shaders runtime closure differs from the capture receipt.",coverage:m};let R=await b(e),S=Object.keys(R),V=Object.keys(d.inputs),P=S.filter(b=>!Object.hasOwn(d.inputs,b)),T=V.filter(b=>!Object.hasOwn(R,b)),f=S.filter(b=>Object.hasOwn(d.inputs,b)&&d.inputs[b]!==R[b]);return P.length>0||T.length>0||f.length>0?{state:"stale",scene:r,reason:`${P.length} added, ${T.length} removed, and ${f.length} changed semantic shader inputs.`,coverage:m,...f.length>0?{changedInputs:f}:{},...P.length>0?{addedInputs:P}:{},...T.length>0?{removedInputs:T}:{}}:{state:"fresh",scene:r,reason:"Manifest, installed shader runtime closure, and the shader-relevant source snapshot match.",coverage:m}}catch(o){return {state:"invalid",scene:r,reason:o instanceof Error?o.message:String(o)}}}a(fe,"inspectShaders");async function ye(e,t){if(t.artifacts?.text==="pending")return {state:"missing",reason:"The template has no verified text artifacts yet.",atlases:[]};let r=await g$1(e);return {state:r.state,reason:r.reason,atlases:r.atlases.map(s=>({name:s.font.key,glyphs:s.codePoints.length,width:s.texture.width,height:s.texture.height}))}}a(ye,"inspectText");function Re(e,t){if(e.lifecycle.assetsReady&&e.assets.codecs.some(r=>!r.available))throw new Error("Runtime status receipt claims assets ready while a configured codec is unavailable.");if(t.features.text!==(e.text!==void 0))throw new Error("Runtime status receipt text observation does not match three-blocks.json.")}a(Re,"validateRuntimeReceiptForProject");async function be(e,t){let r=h.join(e,...te.split("/"));if(!await d(r))return {kind:"absent",receipt:null,reason:"No browser observation receipt is available."};try{let s=await i(e,h.dirname(r),"Runtime status receipt directory"),n=pe(await O(s,h.join(s,h.basename(r)),re,"Runtime status receipt"));return Re(n,t),{kind:"valid",receipt:n,reason:n.error??`Browser observation captured at ${n.observedAt}.`}}catch(s){return {kind:"invalid",receipt:null,reason:`Runtime status receipt is invalid: ${s instanceof Error?s.message:String(s)}`}}}a(be,"inspectRuntimeReceipt");function ge(){return {scene:false,component:false,assetManifest:false,workerRestart:false}}a(ge,"emptyCapabilities");function we(){return {attempted:false,succeeded:null,rollbackPreserved:null,workerRestarted:false}}a(we,"emptyOutcome");function ke(){return []}a(ke,"configuredCodecs");function Se(e,t,r){if(t.state!=="fresh")return "three-blocks shaders capture";if(r!==void 0&&r.state!=="ready")return "three-blocks text generate";let s=e.receipt;return e.kind!=="valid"||s===null||s.lifecycle.state==="error"?H:s.text!==void 0&&s.text.state!=="ready"?"three-blocks text generate":H}a(Se,"recoveryCommand");async function xe(e=process.cwd()){let t=await ee(e),r=b$1(await O(t,h.join(t,"three-blocks.json"),a$2.metadata,"Project metadata")),s=await fe(t,r),n=r.features.text?await ye(t,r):void 0,o=await be(t,r),a=o.receipt,d=o.kind==="invalid",l=d||a?.lifecycle.state==="error",m=a===null?{state:d?"error":"starting",backend:null,renderer:null,protocolVersion:1}:{state:l?"error":a.lifecycle.workerReady?"worker ready":"starting",backend:a.worker.backend,renderer:a.worker.renderer,protocolVersion:a.worker.protocolVersion},y=a===null?{state:d?"error":"starting",codecs:ke(),resources:0}:{state:l?"error":a.lifecycle.assetsReady?"assets ready":"starting",codecs:a.assets.codecs,resources:a.assets.resources},k=a===null?{state:d?"error":"starting",capabilities:ge(),outcome:we()}:{state:l||a.hmr.outcome.attempted&&(a.hmr.outcome.succeeded!==true||a.hmr.outcome.rollbackPreserved!==true)?"error":a.hmr.outcome.attempted?"first frame":"starting",capabilities:a.hmr.capabilities,outcome:a.hmr.outcome},x=a===null?{state:d?"error":"starting",snapshots:0,textures:0,workerProfiler:false,mainPanels:false}:{state:l?"error":a.stats.snapshots>0&&a.stats.workerProfiler&&a.stats.mainPanels?"first frame":"starting",...a.stats},R=a===null?{state:d?"error":"starting",mode:null,pipelines:0,artifactState:s.state}:{state:l?"error":a.lifecycle.compiled?s.state==="fresh"?a.shaders.mode:s.state:a.lifecycle.state,mode:a.shaders.mode,pipelines:a.shaders.pipelines,artifactState:s.state},S=n===void 0?void 0:a?.text===void 0?{state:d?"error":"starting",atlases:0,glyphs:0,requiredGlyphs:0}:{state:l?"error":n.state==="ready"?a.text.state:n.state,atlases:a.text.atlases,glyphs:a.text.glyphs,requiredGlyphs:a.text.requiredGlyphs};return {schemaVersion:1,root:t,metadata:r,configuration:{worker:m,assets:y,hmr:k,optimization:R,stats:x,...S===void 0?{}:{text:S}},runtime:{state:d?"error":a?.lifecycle.state??"starting",observed:a!==null,observedAt:a?.observedAt??null,reason:o.reason,recovery:Se(o,s,n),observation:a},shaders:s,...n?{text:n}:{}}}a(xe,"inspectProject");async function Z(e){let[t,r]=await Promise.all([d(h.join(e,"three-blocks.shaders.json")),d(h.join(e,"three-blocks.text.ts"))]),[s,n]=await Promise.all([t?d$1(e):Promise.resolve(void 0),r?g$1(e):Promise.resolve(void 0)]);return {schemaVersion:1,root:e,kind:"adopted",markers:{shaders:t,text:r},...s===void 0?{}:{shaders:s},...n===void 0?{}:{text:n}}}a(Z,"inspectAdoptedProject");async function qe(e=process.cwd()){let t=await ee(e),r=h.join(t,"three-blocks.json");if(await d(r)){try{b$1(await O(t,r,a$2.metadata,"Project metadata"));}catch{return Z(t)}return xe(t)}return Z(t)}a(qe,"inspectThreeBlocksStatus");function Ge(e){return Q(e)?(e.markers.shaders||e.markers.text)&&(e.shaders===void 0||e.shaders.state==="fresh")&&(e.text===void 0||e.text.state==="ready"):e.shaders.state==="fresh"&&(e.text===void 0||e.text.state==="ready")&&e.runtime.state!=="error"}a(Ge,"threeBlocksStatusIsFresh");function $e(e){return e==="ktx2"?"KTX2":e==="draco"?"Draco":e==="meshopt"?"Meshopt":e}a($e,"codecName");function ve(e,t=Date.now()){let r=t-Date.parse(e);if(!Number.isFinite(r)||r<0)return e;let s=Math.round(r/1e3);if(s<60)return "just now";let n=Math.round(s/60);if(n<60)return `${n} minute${n===1?"":"s"} ago`;let o=Math.round(n/60);return o<48?`${o} hour${o===1?"":"s"} ago`:`${Math.round(o/24)} days ago`}a(ve,"relativeTime");function w(e,t,r){return `${e} ${d$2(t,12)} ${r}`}a(w,"row");function v(e,t){return ` ${d$2(b$2.dim(e),12)} ${b$2.dim(t)}`}a(v,"subRow");function Pe(e){return e<100?e.toFixed(1):Math.round(e).toString()}a(Pe,"milliseconds");function Te(e){return e?`${e.render} render \xB7 ${e.compute} compute`:"no coverage"}a(Te,"coverageText");function je(e){let t=[w(g$2(e.state),"shaders",`${e.state==="fresh"?"fresh":b$2.warn(e.state)} ${c$3.dot} ${b$2.dim(e.reason)}`)];for(let r of e.scenes){let s=r.timing,n=s?.source==="committed-capture"?s.adapter??"captured adapter":"this capture",o=s===void 0?"":s.runs>1?`measured median of ${s.runs}`:"single-capture estimate",a=s===void 0?"":`\u2248${Pe(s.avoidedBuildMs)} ms TSL work avoided`,d=s===void 0?r.state==="fresh"?` ${c$3.dot} ${b$2.dim("capture again to record a timing estimate")}`:"":` ${c$3.dot} ${b$2.dim(`${a} \xB7 ${o} \xB7 ${n}`)}`;t.push(w(g$2(r.state),r.scene,`${r.state} ${c$3.dot} ${Te(r.coverage)}${d}`)),s!==void 0&&s.spreadMs>s.avoidedBuildMs*.4&&t.push(v("measure",b$2.warn("noisy measurement \u2014 close other GPU apps and re-run")));let l=[...r.changedInputs??[],...r.addedInputs??[],...r.removedInputs??[]];l.length>0&&t.push(v("changed",l.join(", ")));}return e.state!=="fresh"&&t.push(`${c$3.info} ${b$2.accent("three-blocks shaders capture")}`),t.join(`
2
+ import {d as d$2,b as b$2,c as c$3,g as g$2}from'./chunk-76WRV5MZ.js';import {g as g$1}from'./chunk-JMS5NTP7.js';import {a as a$3,c as c$2,b,d as d$1}from'./chunk-5RSAQ74G.js';import {a as a$1,c,b as b$1}from'./chunk-ZDNZCQUQ.js';import {j,d,i,a as a$2,c as c$1}from'./chunk-5L2VS3BN.js';import {a}from'./chunk-HOZDD6PW.js';import {realpath}from'fs/promises';import h from'path';var te=".three-blocks/runtime/status.json",re=256*1024,H="three-blocks browser smoke",se=["three-blocks.json","three-blocks.shaders.json","three-blocks.text.ts"];function Q(e){return "kind"in e&&e.kind==="adopted"}a(Q,"isAdoptedProjectStatus");async function O(e,t,r,s){let n=await j(e,t,r,s);return JSON.parse(n.data.toString("utf8"))}a(O,"readJsonWithin");var ne=["starting","worker ready","assets ready","compiled","first frame","updating","error"],ae=["ready","generating","fallback","missing","invalid"],oe=["WebGPU","WebGL"],ie=["OffscreenCanvas","MainThread"],de=/^[0-9A-Za-z][0-9A-Za-z._-]{0,63}$/,X=16,K=1e9;function g(e,t,r,s=[]){if(!a$1(e))throw new Error(`${t} must be an object.`);let n=new Set([...r,...s]);for(let o of r)if(!Object.hasOwn(e,o))throw new Error(`${t}.${o} is required.`);for(let o of Object.keys(e))if(!n.has(o))throw new Error(`${t}.${o} is not supported by schema v1.`);return e}a(g,"exactRecord");function A(e,t,r){if(typeof e!="string"||!t.includes(e))throw new Error(`${r} has an unsupported value.`);return e}a(A,"enumValue");function p(e,t){if(typeof e!="boolean")throw new Error(`${t} must be a boolean.`);return e}a(p,"booleanValue");function Y(e,t){return e===null?null:p(e,t)}a(Y,"nullableBoolean");function E(e,t){if(typeof e!="number"||!Number.isSafeInteger(e)||e<0||e>K)throw new Error(`${t} must be a non-negative integer no greater than ${K}.`);return e}a(E,"boundedCounter");function ce(e){if(typeof e!="string"||e.length>32)throw new Error("Runtime status receipt observedAt must be a bounded ISO timestamp.");let t=Date.parse(e);if(!Number.isFinite(t)||new Date(t).toISOString()!==e)throw new Error("Runtime status receipt observedAt must be an exact ISO timestamp.");return e}a(ce,"observedTimestamp");function ue(e){if(e===null)return null;if(typeof e!="string"||e.length===0||e.length>2048||/[\u0000-\u001f\u007f]/u.test(e))throw new Error("Runtime status receipt error must be null or one bounded display-safe line.");return e}a(ue,"receiptError");function le(e){if(!Array.isArray(e)||e.length>X)throw new Error(`Runtime status receipt assets.codecs must contain at most ${X} entries.`);let t=e.map((r,s)=>{let n=g(r,`Runtime status receipt assets.codecs[${s}]`,["name","available","decoded"]);if(typeof n.name!="string"||!de.test(n.name))throw new Error(`Runtime status receipt assets.codecs[${s}].name is invalid.`);let o=p(n.available,`Runtime status receipt assets.codecs[${s}].available`),a=p(n.decoded,`Runtime status receipt assets.codecs[${s}].decoded`);if(a&&!o)throw new Error(`Runtime status receipt codec ${JSON.stringify(n.name)} cannot be decoded when unavailable.`);return {name:n.name,available:o,decoded:a}});if(new Set(t.map(r=>r.name)).size!==t.length)throw new Error("Runtime status receipt assets.codecs must have unique names.");return t}a(le,"parseRuntimeCodecs");function me(e){if(e.assetsReady&&!e.workerReady)throw new Error("Runtime lifecycle assetsReady requires workerReady.");if(e.compiled&&!e.assetsReady)throw new Error("Runtime lifecycle compiled requires assetsReady.");if(e.firstFrame&&!e.compiled)throw new Error("Runtime lifecycle firstFrame requires compiled.");let t=e.state==="starting"?[false,false,false,false]:e.state==="worker ready"?[true,false,false,false]:e.state==="assets ready"?[true,true,false,false]:e.state==="compiled"?[true,true,true,false]:e.state==="first frame"||e.state==="updating"?[true,true,true,true]:null;if(t!==null&&![e.workerReady,e.assetsReady,e.compiled,e.firstFrame].every((r,s)=>r===t[s]))throw new Error(`Runtime lifecycle flags do not match state ${JSON.stringify(e.state)}.`)}a(me,"validateLifecycle");function pe(e){let t=g(e,"Runtime status receipt",["schemaVersion","observedAt","worker","assets","hmr","stats","lifecycle","shaders","error"],["text"]);if(t.schemaVersion!==1)throw new Error("Runtime status receipt must use schemaVersion 1.");let r=g(t.worker,"Runtime status receipt worker",["backend","renderer","protocolVersion"]);if(r.protocolVersion!==1)throw new Error("Runtime status receipt worker.protocolVersion must be 1.");let s=g(t.assets,"Runtime status receipt assets",["codecs","resources"]),n=g(t.hmr,"Runtime status receipt hmr",["capabilities","outcome"]),o=g(n.capabilities,"Runtime status receipt hmr.capabilities",["scene","component","assetManifest","workerRestart"]),a=g(n.outcome,"Runtime status receipt hmr.outcome",["attempted","succeeded","rollbackPreserved","workerRestarted"]),d=p(a.attempted,"Runtime status receipt hmr.outcome.attempted"),l=Y(a.succeeded,"Runtime status receipt hmr.outcome.succeeded"),m=Y(a.rollbackPreserved,"Runtime status receipt hmr.outcome.rollbackPreserved"),y=p(a.workerRestarted,"Runtime status receipt hmr.outcome.workerRestarted");if(d?l===null||m===null:l!==null||m!==null||y)throw new Error("Runtime status receipt HMR outcome fields are inconsistent with attempted.");let k={scene:p(o.scene,"Runtime status receipt hmr.capabilities.scene"),component:p(o.component,"Runtime status receipt hmr.capabilities.component"),assetManifest:p(o.assetManifest,"Runtime status receipt hmr.capabilities.assetManifest"),workerRestart:p(o.workerRestart,"Runtime status receipt hmr.capabilities.workerRestart")};if(d&&!k.scene)throw new Error("Runtime status receipt cannot attempt HMR without the scene capability.");if(y&&!k.workerRestart)throw new Error("Runtime status receipt cannot restart a worker without the workerRestart capability.");let x=g(t.stats,"Runtime status receipt stats",["snapshots","textures","workerProfiler","mainPanels"]),R=g(t.lifecycle,"Runtime status receipt lifecycle",["state","workerReady","assetsReady","compiled","firstFrame"]),S={state:A(R.state,ne,"Runtime status receipt lifecycle.state"),workerReady:p(R.workerReady,"Runtime status receipt lifecycle.workerReady"),assetsReady:p(R.assetsReady,"Runtime status receipt lifecycle.assetsReady"),compiled:p(R.compiled,"Runtime status receipt lifecycle.compiled"),firstFrame:p(R.firstFrame,"Runtime status receipt lifecycle.firstFrame")};me(S);let V=g(t.shaders,"Runtime status receipt shaders",["mode","pipelines"]),P=A(V.mode,["precompiled","live"],"Runtime status receipt shaders.mode"),T=E(V.pipelines,"Runtime status receipt shaders.pipelines");if(P==="precompiled"&&T===0)throw new Error("A precompiled runtime receipt must observe at least one shader pipeline.");let f;if(t.text!==void 0){let I=g(t.text,"Runtime status receipt text",["state","atlases","glyphs","requiredGlyphs"]);if(f={state:A(I.state,ae,"Runtime status receipt text.state"),atlases:E(I.atlases,"Runtime status receipt text.atlases"),glyphs:E(I.glyphs,"Runtime status receipt text.glyphs"),requiredGlyphs:E(I.requiredGlyphs,"Runtime status receipt text.requiredGlyphs")},f.state==="ready"&&(f.atlases===0||f.requiredGlyphs===0||f.glyphs<f.requiredGlyphs))throw new Error("A ready text receipt must cover a non-empty required glyph set with at least one atlas.")}let b=ue(t.error);if(S.state==="error"?b===null:b!==null)throw new Error("Runtime status receipt error must be present only when lifecycle.state is error.");return {schemaVersion:1,observedAt:ce(t.observedAt),worker:{backend:A(r.backend,ie,"Runtime status receipt worker.backend"),renderer:A(r.renderer,oe,"Runtime status receipt worker.renderer"),protocolVersion:1},assets:{codecs:le(s.codecs),resources:E(s.resources,"Runtime status receipt assets.resources")},hmr:{capabilities:k,outcome:{attempted:d,succeeded:l,rollbackPreserved:m,workerRestarted:y}},stats:{snapshots:E(x.snapshots,"Runtime status receipt stats.snapshots"),textures:E(x.textures,"Runtime status receipt stats.textures"),workerProfiler:p(x.workerProfiler,"Runtime status receipt stats.workerProfiler"),mainPanels:p(x.mainPanels,"Runtime status receipt stats.mainPanels")},lifecycle:S,shaders:{mode:P,pipelines:T},...f===void 0?{}:{text:f},error:b}}a(pe,"parseRuntimeStatusReceipt");function he(e,t){return e.render===t.render&&e.vertex===t.vertex&&e.fragment===t.fragment&&e.compute===t.compute}a(he,"sameCoverage");async function ee(e=process.cwd()){let t=h.resolve(e);for(;;){if((await Promise.all(se.map(s=>d(h.join(t,s))))).some(Boolean))return realpath(t);let r=h.dirname(t);if(r===t)return realpath(h.resolve(e));t=r;}}a(ee,"findProjectRoot");async function fe(e,t){let r=t.template,s=h.join(e,".three-blocks","shaders"),n=h.join(s,"meta.json");if(!await d(s)||!await d(n))return {state:"missing",scene:r,reason:t.artifacts?.shaders==="pending"?"The selected template has no verified shader capture yet.":".three-blocks/shaders/meta.json is absent."};try{let o=await i(e,s,"Shader artifact directory"),a=c(await O(o,n,a$2.receipt,"Shader receipt")),d=a.scenes[r];if(d===void 0)return {state:"invalid",scene:r,reason:`Shader receipt has no "${r}" scene.`};let l=await j(o,h.join(o,d.artifact),a$2.manifest,"Shader manifest");if(c$1(l.data)!==d.artifactHash)return {state:"invalid",scene:r,reason:"The selected shader manifest checksum does not match its receipt."};let m=a$3(l.data.toString("utf8"),l.path,r);if(!he(m,d.coverage))return {state:"invalid",scene:r,reason:"Shader receipt coverage does not match the manifest entries.",coverage:m};let{three:y,threeBlocks:k,threeBlocksShaderClosure:x}=await c$2(e);if(a.runtime.three!==y||t.runtime.three!==y||a.runtime.threeBlocks!==k||t.runtime.threeBlocks!==k)return {state:"stale",scene:r,reason:`Installed runtime versions (${y}, ${k}) do not match the metadata and shader receipt.`,coverage:m};if(a.runtime.threeBlocksShaderClosure!==x)return {state:"stale",scene:r,reason:"The installed three-blocks/shaders runtime closure differs from the capture receipt.",coverage:m};let R=await b(e),S=Object.keys(R),V=Object.keys(d.inputs),P=S.filter(b=>!Object.hasOwn(d.inputs,b)),T=V.filter(b=>!Object.hasOwn(R,b)),f=S.filter(b=>Object.hasOwn(d.inputs,b)&&d.inputs[b]!==R[b]);return P.length>0||T.length>0||f.length>0?{state:"stale",scene:r,reason:`${P.length} added, ${T.length} removed, and ${f.length} changed semantic shader inputs.`,coverage:m,...f.length>0?{changedInputs:f}:{},...P.length>0?{addedInputs:P}:{},...T.length>0?{removedInputs:T}:{}}:{state:"fresh",scene:r,reason:"Manifest, installed shader runtime closure, and the shader-relevant source snapshot match.",coverage:m}}catch(o){return {state:"invalid",scene:r,reason:o instanceof Error?o.message:String(o)}}}a(fe,"inspectShaders");async function ye(e,t){if(t.artifacts?.text==="pending")return {state:"missing",reason:"The template has no verified text artifacts yet.",atlases:[]};let r=await g$1(e);return {state:r.state,reason:r.reason,atlases:r.atlases.map(s=>({name:s.font.key,glyphs:s.codePoints.length,width:s.texture.width,height:s.texture.height}))}}a(ye,"inspectText");function Re(e,t){if(e.lifecycle.assetsReady&&e.assets.codecs.some(r=>!r.available))throw new Error("Runtime status receipt claims assets ready while a configured codec is unavailable.");if(t.features.text!==(e.text!==void 0))throw new Error("Runtime status receipt text observation does not match three-blocks.json.")}a(Re,"validateRuntimeReceiptForProject");async function be(e,t){let r=h.join(e,...te.split("/"));if(!await d(r))return {kind:"absent",receipt:null,reason:"No browser observation receipt is available."};try{let s=await i(e,h.dirname(r),"Runtime status receipt directory"),n=pe(await O(s,h.join(s,h.basename(r)),re,"Runtime status receipt"));return Re(n,t),{kind:"valid",receipt:n,reason:n.error??`Browser observation captured at ${n.observedAt}.`}}catch(s){return {kind:"invalid",receipt:null,reason:`Runtime status receipt is invalid: ${s instanceof Error?s.message:String(s)}`}}}a(be,"inspectRuntimeReceipt");function ge(){return {scene:false,component:false,assetManifest:false,workerRestart:false}}a(ge,"emptyCapabilities");function we(){return {attempted:false,succeeded:null,rollbackPreserved:null,workerRestarted:false}}a(we,"emptyOutcome");function ke(){return []}a(ke,"configuredCodecs");function Se(e,t,r){if(t.state!=="fresh")return "three-blocks shaders capture";if(r!==void 0&&r.state!=="ready")return "three-blocks text generate";let s=e.receipt;return e.kind!=="valid"||s===null||s.lifecycle.state==="error"?H:s.text!==void 0&&s.text.state!=="ready"?"three-blocks text generate":H}a(Se,"recoveryCommand");async function xe(e=process.cwd()){let t=await ee(e),r=b$1(await O(t,h.join(t,"three-blocks.json"),a$2.metadata,"Project metadata")),s=await fe(t,r),n=r.features.text?await ye(t,r):void 0,o=await be(t,r),a=o.receipt,d=o.kind==="invalid",l=d||a?.lifecycle.state==="error",m=a===null?{state:d?"error":"starting",backend:null,renderer:null,protocolVersion:1}:{state:l?"error":a.lifecycle.workerReady?"worker ready":"starting",backend:a.worker.backend,renderer:a.worker.renderer,protocolVersion:a.worker.protocolVersion},y=a===null?{state:d?"error":"starting",codecs:ke(),resources:0}:{state:l?"error":a.lifecycle.assetsReady?"assets ready":"starting",codecs:a.assets.codecs,resources:a.assets.resources},k=a===null?{state:d?"error":"starting",capabilities:ge(),outcome:we()}:{state:l||a.hmr.outcome.attempted&&(a.hmr.outcome.succeeded!==true||a.hmr.outcome.rollbackPreserved!==true)?"error":a.hmr.outcome.attempted?"first frame":"starting",capabilities:a.hmr.capabilities,outcome:a.hmr.outcome},x=a===null?{state:d?"error":"starting",snapshots:0,textures:0,workerProfiler:false,mainPanels:false}:{state:l?"error":a.stats.snapshots>0&&a.stats.workerProfiler&&a.stats.mainPanels?"first frame":"starting",...a.stats},R=a===null?{state:d?"error":"starting",mode:null,pipelines:0,artifactState:s.state}:{state:l?"error":a.lifecycle.compiled?s.state==="fresh"?a.shaders.mode:s.state:a.lifecycle.state,mode:a.shaders.mode,pipelines:a.shaders.pipelines,artifactState:s.state},S=n===void 0?void 0:a?.text===void 0?{state:d?"error":"starting",atlases:0,glyphs:0,requiredGlyphs:0}:{state:l?"error":n.state==="ready"?a.text.state:n.state,atlases:a.text.atlases,glyphs:a.text.glyphs,requiredGlyphs:a.text.requiredGlyphs};return {schemaVersion:1,root:t,metadata:r,configuration:{worker:m,assets:y,hmr:k,optimization:R,stats:x,...S===void 0?{}:{text:S}},runtime:{state:d?"error":a?.lifecycle.state??"starting",observed:a!==null,observedAt:a?.observedAt??null,reason:o.reason,recovery:Se(o,s,n),observation:a},shaders:s,...n?{text:n}:{}}}a(xe,"inspectProject");async function Z(e){let[t,r]=await Promise.all([d(h.join(e,"three-blocks.shaders.json")),d(h.join(e,"three-blocks.text.ts"))]),[s,n]=await Promise.all([t?d$1(e):Promise.resolve(void 0),r?g$1(e):Promise.resolve(void 0)]);return {schemaVersion:1,root:e,kind:"adopted",markers:{shaders:t,text:r},...s===void 0?{}:{shaders:s},...n===void 0?{}:{text:n}}}a(Z,"inspectAdoptedProject");async function qe(e=process.cwd()){let t=await ee(e),r=h.join(t,"three-blocks.json");if(await d(r)){try{b$1(await O(t,r,a$2.metadata,"Project metadata"));}catch{return Z(t)}return xe(t)}return Z(t)}a(qe,"inspectThreeBlocksStatus");function Ge(e){return Q(e)?(e.markers.shaders||e.markers.text)&&(e.shaders===void 0||e.shaders.state==="fresh")&&(e.text===void 0||e.text.state==="ready"):e.shaders.state==="fresh"&&(e.text===void 0||e.text.state==="ready")&&e.runtime.state!=="error"}a(Ge,"threeBlocksStatusIsFresh");function $e(e){return e==="ktx2"?"KTX2":e==="draco"?"Draco":e==="meshopt"?"Meshopt":e}a($e,"codecName");function ve(e,t=Date.now()){let r=t-Date.parse(e);if(!Number.isFinite(r)||r<0)return e;let s=Math.round(r/1e3);if(s<60)return "just now";let n=Math.round(s/60);if(n<60)return `${n} minute${n===1?"":"s"} ago`;let o=Math.round(n/60);return o<48?`${o} hour${o===1?"":"s"} ago`:`${Math.round(o/24)} days ago`}a(ve,"relativeTime");function w(e,t,r){return `${e} ${d$2(t,12)} ${r}`}a(w,"row");function v(e,t){return ` ${d$2(b$2.dim(e),12)} ${b$2.dim(t)}`}a(v,"subRow");function Pe(e){return e<100?e.toFixed(1):Math.round(e).toString()}a(Pe,"milliseconds");function Te(e){return e?`${e.render} render \xB7 ${e.compute} compute`:"no coverage"}a(Te,"coverageText");function je(e){let t=[w(g$2(e.state),"shaders",`${e.state==="fresh"?"fresh":b$2.warn(e.state)} ${c$3.dot} ${b$2.dim(e.reason)}`)];for(let r of e.scenes){let s=r.timing,n=s?.source==="committed-capture"?s.adapter??"captured adapter":"this capture",o=s===void 0?"":s.runs>1?`measured median of ${s.runs}`:"single-capture estimate",a=s===void 0?"":`\u2248${Pe(s.avoidedBuildMs)} ms TSL work avoided`,d=s===void 0?r.state==="fresh"?` ${c$3.dot} ${b$2.dim("capture again to record a timing estimate")}`:"":` ${c$3.dot} ${b$2.dim(`${a} \xB7 ${o} \xB7 ${n}`)}`;t.push(w(g$2(r.state),r.scene,`${r.state} ${c$3.dot} ${Te(r.coverage)}${d}`)),s!==void 0&&s.spreadMs>s.avoidedBuildMs*.4&&t.push(v("measure",b$2.warn("noisy measurement \u2014 close other GPU apps and re-run")));let l=[...r.changedInputs??[],...r.addedInputs??[],...r.removedInputs??[]];l.length>0&&t.push(v("changed",l.join(", ")));}return e.state!=="fresh"&&t.push(`${c$3.info} ${b$2.accent("three-blocks shaders capture")}`),t.join(`
3
3
  `)}a(je,"formatShaderMatrixStatus");function Ee(e){let t=e.scene,r=e.coverage,s=r?`${r.render} render \xB7 ${r.compute} compute`:"no coverage";if(e.state==="fresh")return [w(g$2("fresh"),t,`fresh ${c$3.dot} ${s} ${c$3.dot} ${b$2.dim("precompiled at runtime")}`)];let n=[w(g$2(e.state),t,`${e.state==="missing"?b$2.dim("missing"):b$2.warn(e.state)} ${c$3.dot} ${b$2.dim(e.reason)}`)],o=[...e.changedInputs??[],...e.addedInputs??[],...e.removedInputs??[]];return o.length>0&&n.push(v("changed",o.join(", "))),n}a(Ee,"shaderRow");function Me(e,t=Date.now()){let r=c$3.mark?`${c$3.mark} `:"",s=e.metadata.runtime,n=[`${r}${b$2.bold("three-blocks")} ${b$2.dim("status")}`,v("project",e.root),"",b$2.bold("Project"),w(c$3.tick,e.metadata.template,`three ${s.three} ${c$3.dot} three-blocks ${s.threeBlocks}`),"",b$2.bold("Shaders"),...Ee(e.shaders)];if(e.text){let d=e.text,l=d.atlases.reduce((m,y)=>m+y.glyphs,0);n.push("",b$2.bold("Text"),w(g$2(d.state),"coverage",d.state==="ready"?`ready ${c$3.dot} ${l} glyphs ${c$3.dot} ${d.atlases.length} atlas${d.atlases.length===1?"":"es"}`:`${b$2.warn(d.state)} ${c$3.dot} ${b$2.dim(d.reason)}`),...d.atlases.map(m=>v("atlas",`${m.name} \xB7 ${m.glyphs} glyphs \xB7 ${m.width}\xD7${m.height}`)));}let o=e.runtime.observation;if(n.push("",b$2.bold("Browser check")),o!==null&&e.runtime.state!=="error"){let d=o.assets.codecs.map(l=>`${$e(l.name)}${l.decoded?"":l.available?" (idle)":" (unavailable)"}`).join(" \xB7 ");n.push(w(c$3.tick,"verified",`${ve(o.observedAt,t)} ${c$3.dot} ${o.worker.renderer} worker ${c$3.dot} ${o.lifecycle.state} ${c$3.dot} ${o.shaders.pipelines} pipeline${o.shaders.pipelines===1?"":"s"} ${o.shaders.mode}`),v("codecs",d||"none configured")),o.hmr.outcome.attempted&&n.push(v("hmr",o.hmr.outcome.succeeded?`update succeeded${o.hmr.outcome.workerRestarted?" \xB7 worker restarted":""}`:"update failed"));}else e.runtime.state==="error"?n.push(w(c$3.cross,"runtime",b$2.danger(e.runtime.reason))):n.push(w(c$3.ring,"unverified",b$2.dim(`no browser run recorded \u2014 ${H}`)));return e.shaders.state==="fresh"&&(e.text===void 0||e.text.state==="ready")&&e.runtime.state!=="error"||n.push("",b$2.bold("Next"),`${c$3.info} ${b$2.accent(e.runtime.recovery)}`),n.join(`
4
4
  `)}a(Me,"formatStatus");function He(e,t=Date.now()){if(!Q(e))return Me(e,t);let r=c$3.mark?`${c$3.mark} `:"",s=e.markers.shaders||e.markers.text,n=[`${r}${b$2.bold("three-blocks")} ${b$2.dim("status")}`,v("project",e.root)];if(!s)return n.push("",`${c$3.dot} ${b$2.dim("no Three Blocks project markers found")}`,` ${b$2.dim("shaders:")} add three-blocks.shaders.json \u2014 /docs/tools/devtools`,` ${b$2.dim("starter:")} npx three-blocks starter`),n.join(`
5
5
  `);if(e.shaders!==void 0&&n.push("",b$2.bold("Shaders"),je(e.shaders)),e.text!==void 0){let o=e.text.atlases.reduce((a,d)=>a+d.codePoints.length,0);n.push("",b$2.bold("Text"),w(g$2(e.text.state),"coverage",e.text.state==="ready"?`ready ${c$3.dot} ${o} glyphs ${c$3.dot} ${e.text.atlases.length} atlas${e.text.atlases.length===1?"":"es"}`:`${b$2.warn(e.text.state)} ${c$3.dot} ${b$2.dim(e.text.reason)}`));}return n.join(`
package/dist/cli.js CHANGED
@@ -5,20 +5,20 @@ ${e}
5
5
  `:t),n.includes("--yes"))return true;if(!a.stdin.isTTY||!a.stderr.isTTY)throw new Error("Adapter wiring needs consent. Review the diff above, then rerun with --yes; no files were changed.");let{createInterface:i}=await import('readline/promises'),r=i({input:a.stdin,output:a.stderr});try{let c=await r.question("Apply this patch? (y/N) ");return /^y(?:es)?$/iu.test(c.trim())}finally{r.close();}}a$1(ce,"approveAdapterPatch");function C(e){return w?{update(){},stop(){}}:h(e)}a$1(C,"wait");function le(){let e$1=a$1(f=>b$1.accent(f),"c"),t=a$1(f=>b$1.dim(f),"d"),i=c.mark?`${c.mark} `:"",r=[["Inspect",[[`${e$1("status")}`,`project report: shaders, text, browser evidence ${t("\u2014 no browser, no GPU")}`],[`${e$1("shaders")}`,"verify shader freshness and exit 1 with the exact recovery command"],[`${e$1("shaders status")} ${t("[--check]")}`,`per-scene shader freshness ${t("(--check exits 1 when not fresh)")}`],[`${e$1("text status")}`,"text atlas coverage"]]],["Produce",[[`${e$1("shaders capture")} ${t("[--if-stale] [--commit-timing] [--driver static --serve dist]")}`,"capture shaders plus a local timing estimate; during development use the overlay Capture button"],[`${e$1("shaders watch")} ${t("[--debounce <ms>]")}`,"recapture automatically while you work"],[`${e$1("text generate")} ${t("[--config <path>]")}`,"regenerate MSDF text atlases"],[`${e$1("environment bake")} ${t("[--size 256]")}`,"bake the PMREM room environment to KTX2"]]],["Verify",[[`${e$1("shaders test")}`,"median timing + zero-build + compute + pixel parity gate"],[`${e$1("shaders test --parity-only")}`,"one correctness pair per scene; no timing or published-page soak"],[`${e$1("browser smoke")} ${t("[--route /] [--hmr <module>]")}`,"boot the dev app, verify worker lifecycle + HMR"],[`${e$1("browser preview")} ${t("[--route /]...")}`,"build + serve production, verify precompiled hydration"]]]],c$1=["",`${i}${b$1.bold("three-blocks devtools")} ${b$1.dim(`v${a$2}`)}`,b$1.dim("WebGPU shader precompilation and verification for Three Blocks projects."),"",`${b$1.bold("Usage")}`,` ${e$1("three-blocks-devtools")} ${t("[command] [options] [--json]")}`];for(let[f,d]of r)c$1.push("",b$1.bold(f),...e(d,{indent:2,maxWidth:a$3.width-2}));c$1.push("",b$1.bold("Options"),...e([[t("--json"),"stable machine-readable report on stdout"],[t("--reporter <plain|json>"),"select the stable terminal or CI reporter"],[t("--root <path>"),"project root (defaults to the nearest three-blocks project)"],[t("--headed"),"show the automation browser window"],[t("--runs <n>"),"shader timing captures after warmup (default 5)"],[t("--parity-only"),"skip timing warmup/repeats and the published-page soak"],[t("--commit-timing"),"also write shareable hardware-labelled build timing"],[t("--skip-browser"),"check shader schema and freshness without browser parity"],[t("--driver <vite|static>"),"capture through Vite or an already-built static app"],[t("--serve <path>"),"built application directory for --driver static"],[t("--url <url>"),"attach to an already-running transformed application"],[t("--yes"),"apply a previewed framework adapter patch non-interactively"]],{indent:2,maxWidth:a$3.width-2}),"",b$1.dim("During development, use the in-page overlay Capture button for one-click recapture."),b$1.dim("`shaders capture` remains the explicit isolated-browser fallback for batch and CI."),""),f(c$1.join(`
6
6
  `));}a$1(le,"help");function pe(e){return e?`${e.render} render \xB7 ${e.compute} compute`:"no coverage"}a$1(pe,"coverageText");function Q(e){return e<100?e.toFixed(1):Math.round(e).toString()}a$1(Q,"milliseconds");function A(e,t,i){return `${e} ${d(t,12)} ${i}`}a$1(A,"row");function oe(e$1){if(e$1.skipped)return A(c.tick,"shaders",`fresh ${c.dot} capture skipped ${b$1.dim(`(--if-stale) \xB7 ${e$1.reason}`)}`);let t=Math.max(0,Math.round((e$1.durationMs??0)/1e3)),i=e$1.scenes.length,r=[A(c.tick,"shaders",`captured in ${t} s ${c.dot} wrote ${i} shader scene${i===1?"":"s"}`)];e$1.configuration?.created===true&&r.push(b$1.dim(` created ${e$1.configuration.file} with the default "/" capture route`));for(let f of e$1.scenes)r.push(A(c.tick,f.scene,`${pe(f.coverage)} ${c.dot} ${b$1.dim(`${f.attempts} attempt${f.attempts===1?"":"s"}`)}`));let c$1=e$1.scenes.flatMap(f=>{let d=f.timing;if(d?.launch===void 0||d.firstRequest===void 0||d.readiness===void 0||d.lastBuild===void 0||d.settled===void 0||d.posted===void 0)return [];let m=a$1((M,l)=>`${Q(Math.max(0,l-M))} ms`,"elapsed");return [[f.scene,`launch\u2192request ${m(d.launch,d.firstRequest)} ${c.dot} ready ${m(d.firstRequest,d.readiness)} ${c.dot} last build ${m(d.readiness,d.lastBuild)} ${c.dot} settle ${m(d.lastBuild,d.settled)} ${c.dot} post ${m(d.settled,d.posted)}`]]});return c$1.length>0&&r.push("",b$1.bold("Capture stages"),...e(c$1,{indent:2,maxWidth:a$3.width-2})),e$1.measurement!==void 0&&r.push(` TSL builds at startup: ${e$1.measurement.beforeBuilds} \u2192 ${e$1.measurement.afterBuilds} ${c.dot} \u2248${Q(Math.abs(e$1.measurement.firstFrameDeltaMs))} ms TSL work avoided (single-capture estimate)`),r.push(b$1.dim(" a running dev server reloads on its own; otherwise refresh the page")),r.join(`
7
7
  `)}a$1(oe,"formatShaderCapture");function fe(e){let t=[A(c.tick,"shaders",`no-GPU ${e.noGpu.state} ${c.dot} browser ${e.browser}`)];for(let i of e.scenes){let r=e.timing?.scenes[i.scene],c$1=r===void 0?`${i.coverage.render+i.coverage.compute} TSL build${i.coverage.render+i.coverage.compute===1?"":"s"} skipped`:`${r.builds} TSL build${r.builds===1?"":"s"} skipped ${c.dot} \u2248${Q(r.avoidedBuildMs)} ms \xB1 ${Q(r.spreadMs)} TSL work avoided ${c.dot} median of ${r.runs} ${c.dot} Latest local capture`,f=r!==void 0&&r.spreadMs>r.avoidedBuildMs*.4?` ${c.dot} ${b$1.warn("noisy measurement \u2014 close other GPU apps and re-run")}`:"";t.push(A(c.tick,i.scene,`${c$1} ${c.dot} ${i.coverage.compute} compute ${c.dot} ${(i.parity.diffRatio*100).toFixed(3)}% pixel diff${f}`));}return t.join(`
8
- `)}a$1(fe,"formatShaderTest");async function he(){if(se!==void 0)throw new Error(se);if(y==="help"||y==="--help"||n.includes("--help"))return le();if(y==="version"||n.includes("--version")){f(w?JSON.stringify({version:a$2}):a$2);return}if(y==="browser"){let{formatBrowserPreviewReport:d,formatBrowserSmokeReport:m,runBrowserPreview:M,runBrowserSmoke:l}=await import('./browser-smoke-MKYIJVVA.js'),{findProjectRoot:S}=await import('./status-76TXXSRT.js');if(E==="preview"){let U=b("--root")??await S(),j=ue("--route"),I=b("--build-mode"),P=b("--expect-shaders")??"precompiled";if(P!=="precompiled"&&P!=="live")throw new Error('--expect-shaders must be "precompiled" or "live".');let T=$("--width"),B=$("--height"),J=$("--timeout"),D=$("--settle"),O=$("--min-luminance"),z=C("building and verifying the production bundle"),o;try{o=await M({root:U,...j.length===0?{}:{routes:j},...I===void 0?{}:{buildMode:I},expectShaders:P,text:n.includes("--text"),...J===void 0?{}:{timeoutMs:J},...D===void 0?{}:{settleMs:D},...O===void 0?{}:{minimumLuminance:O},...T===void 0&&B===void 0?{}:{viewport:{width:T??1024,height:B??640}},headed:n.includes("--headed")});}finally{z.stop();}a.stdout.write(`${w?JSON.stringify(o,null,2):d(o)}
8
+ `)}a$1(fe,"formatShaderTest");async function he(){if(se!==void 0)throw new Error(se);if(y==="help"||y==="--help"||n.includes("--help"))return le();if(y==="version"||n.includes("--version")){f(w?JSON.stringify({version:a$2}):a$2);return}if(y==="browser"){let{formatBrowserPreviewReport:d,formatBrowserSmokeReport:m,runBrowserPreview:M,runBrowserSmoke:l}=await import('./browser-smoke-FPR2OZ37.js'),{findProjectRoot:S}=await import('./status-GATTL2MS.js');if(E==="preview"){let U=b("--root")??await S(),j=ue("--route"),I=b("--build-mode"),P=b("--expect-shaders")??"precompiled";if(P!=="precompiled"&&P!=="live")throw new Error('--expect-shaders must be "precompiled" or "live".');let T=$("--width"),B=$("--height"),J=$("--timeout"),D=$("--settle"),O=$("--min-luminance"),z=C("building and verifying the production bundle"),o;try{o=await M({root:U,...j.length===0?{}:{routes:j},...I===void 0?{}:{buildMode:I},expectShaders:P,text:n.includes("--text"),...J===void 0?{}:{timeoutMs:J},...D===void 0?{}:{settleMs:D},...O===void 0?{}:{minimumLuminance:O},...T===void 0&&B===void 0?{}:{viewport:{width:T??1024,height:B??640}},headed:n.includes("--headed")});}finally{z.stop();}a.stdout.write(`${w?JSON.stringify(o,null,2):d(o)}
9
9
  `),o.passed||(a.exitCode=1);return}if(E!=="smoke")throw new Error(`Unsupported browser command "${E??""}".`);let x=b("--root")??await S(),h=$("--width"),k=$("--height"),R=b("--route"),_=$("--timeout"),q=$("--settle"),L=$("--min-luminance"),g=b("--hmr");if(n.includes("--webgl")&&n.includes("--unsupported-worker"))throw new Error("--webgl and --unsupported-worker are mutually exclusive.");let W=C(`smoking ${R??"/"} in a real browser`),v;try{v=await l({root:x,...R===void 0?{}:{route:R},..._===void 0?{}:{timeoutMs:_},...q===void 0?{}:{settleMs:q},...L===void 0?{}:{minimumLuminance:L},...g===void 0?{}:{hmrModule:g},forceWebgl:n.includes("--webgl"),unsupportedWorker:n.includes("--unsupported-worker"),expectTextGenerationFailure:n.includes("--expect-text-generation-failure"),...h===void 0&&k===void 0?{}:{viewport:{width:h??1024,height:k??640}},headed:n.includes("--headed")});}finally{W.stop();}a.stdout.write(`${w?JSON.stringify(v,null,2):m(v)}
10
- `),v.passed||(a.exitCode=1);return}if(y==="environment"){if(E!=="bake")throw new Error(`Unsupported environment command "${E??""}".`);let{bakeRoomEnvironment:d,formatEnvironmentBakeReport:m}=await import('./environment-bake-5P4IAL4O.js'),{findProjectRoot:M}=await import('./status-76TXXSRT.js'),l=b("--root")??await M(),S=$("--size"),x=b("--output"),h=$("--timeout"),k=C("baking the room environment on the GPU"),R;try{R=await d({root:l,...S===void 0?{}:{size:S},...x===void 0?{}:{output:x},...h===void 0?{}:{timeoutMs:h},compression:n.includes("--no-zstd")?"none":"zstd",headed:n.includes("--headed")});}finally{k.stop();}a.stdout.write(`${w?JSON.stringify(R,null,2):m(R)}
11
- `);return}if(y==="shaders"){let{findShaderProjectRoot:d}=await import('./shader-config-BYBJUL3C.js'),m=E??"status";if(!["status","capture","test","watch"].includes(m))throw new Error(`Unsupported shader command "${m}".`);let M=b("--root"),l=await d(M),S=b("--driver");if(S!==void 0&&S!=="vite"&&S!=="static")throw new Error('--driver must be "vite" or "static".');let x=S,h=b("--serve"),k=b("--url");if(m==="status"){let{inspectShaderMatrix:g}=await import('./shader-workflow-AAH3FM4U.js'),{formatShaderMatrixStatus:W}=await import('./status-76TXXSRT.js'),v=await g(l);a.stdout.write(`${w?JSON.stringify(v,null,2):W(v)}
12
- `),(n.includes("--check")||E===void 0)&&v.state!=="fresh"&&(a.exitCode=1);return}if(m==="capture"){let{captureShaders:g}=await import('./shader-workflow-AAH3FM4U.js'),{applyShaderAutoWire:W,hasRegisterDevtoolsCall:v,inspectShaderAutoWire:U}=await import('./shader-autowire-DCODBFMX.js'),{buildShaderCaptureProject:j,startNextShaderCaptureServer:I}=await import('./shader-project-runner-GUR3LTYS.js'),{inferShaderCaptureTarget:P}=await import('./shader-config-BYBJUL3C.js'),T=x,B=h,J=k,D,O,z;try{if(T===void 0&&B===void 0&&J===void 0){let o=await U(l);if(!o.configured&&o.plan!==void 0){if(!await ce(o.plan.diff))throw new Error("Adapter wiring was declined; no files were changed.");await W(o.plan);}else if(!o.configured&&o.bundler!=="vite"&&o.bundler!=="unknown")throw new Error(`${o.reason} No files were changed.`);if(o.bundler==="next")O=C("starting the project-local Next.js capture server"),D=await I(l),J=D.url,O.update("capturing shader scenes");else if(o.bundler==="webpack"||o.bundler==="esbuild"||o.bundler==="rollup"){O=C(`building the ${o.bundler} capture target`),await j(l);let N=await P(l);if(N.driverKind!=="static"||N.serve===void 0)throw new Error(`${o.bundler} build completed but no dist/, build/, or out/index.html was found; pass --driver static --serve <directory>.`);T="static",B=N.serve,O.update("capturing shader scenes");}}O??=C("capturing shader scenes"),z=await g({root:l,headed:n.includes("--headed"),ifStale:n.includes("--if-stale"),commitTiming:n.includes("--commit-timing"),...T===void 0?{}:{driverKind:T},...B===void 0?{}:{serve:B},...J===void 0?{}:{url:J},onSceneStart:a$1((o,N,K)=>O?.update(`capturing ${b$1.accent(o)} ${b$1.dim(`(${N+1}/${K})`)}`),"onSceneStart"),onSceneRetry:a$1((o,N,K,re,V)=>{let ae=V instanceof Error&&/timed out/iu.test(V.message),ne=`capture attempt ${N}/${K} for "${o}" after ${ae?`timeout (${Math.round(re/1e3)} s burned)`:`failure (${V instanceof Error?V.message:String(V)})`}`;a.stderr.write(w?`${JSON.stringify({type:"shader-capture-retry",scene:o,attempt:N,total:K,timeoutMs:re,message:ne})}
10
+ `),v.passed||(a.exitCode=1);return}if(y==="environment"){if(E!=="bake")throw new Error(`Unsupported environment command "${E??""}".`);let{bakeRoomEnvironment:d,formatEnvironmentBakeReport:m}=await import('./environment-bake-5P4IAL4O.js'),{findProjectRoot:M}=await import('./status-GATTL2MS.js'),l=b("--root")??await M(),S=$("--size"),x=b("--output"),h=$("--timeout"),k=C("baking the room environment on the GPU"),R;try{R=await d({root:l,...S===void 0?{}:{size:S},...x===void 0?{}:{output:x},...h===void 0?{}:{timeoutMs:h},compression:n.includes("--no-zstd")?"none":"zstd",headed:n.includes("--headed")});}finally{k.stop();}a.stdout.write(`${w?JSON.stringify(R,null,2):m(R)}
11
+ `);return}if(y==="shaders"){let{findShaderProjectRoot:d}=await import('./shader-config-BYBJUL3C.js'),m=E??"status";if(!["status","capture","test","watch"].includes(m))throw new Error(`Unsupported shader command "${m}".`);let M=b("--root"),l=await d(M),S=b("--driver");if(S!==void 0&&S!=="vite"&&S!=="static")throw new Error('--driver must be "vite" or "static".');let x=S,h=b("--serve"),k=b("--url");if(m==="status"){let{inspectShaderMatrix:g}=await import('./shader-workflow-I2RA75GO.js'),{formatShaderMatrixStatus:W}=await import('./status-GATTL2MS.js'),v=await g(l);a.stdout.write(`${w?JSON.stringify(v,null,2):W(v)}
12
+ `),(n.includes("--check")||E===void 0)&&v.state!=="fresh"&&(a.exitCode=1);return}if(m==="capture"){let{captureShaders:g}=await import('./shader-workflow-I2RA75GO.js'),{applyShaderAutoWire:W,hasRegisterDevtoolsCall:v,inspectShaderAutoWire:U}=await import('./shader-autowire-DCODBFMX.js'),{buildShaderCaptureProject:j,startNextShaderCaptureServer:I}=await import('./shader-project-runner-GUR3LTYS.js'),{inferShaderCaptureTarget:P}=await import('./shader-config-BYBJUL3C.js'),T=x,B=h,J=k,D,O,z;try{if(T===void 0&&B===void 0&&J===void 0){let o=await U(l);if(!o.configured&&o.plan!==void 0){if(!await ce(o.plan.diff))throw new Error("Adapter wiring was declined; no files were changed.");await W(o.plan);}else if(!o.configured&&o.bundler!=="vite"&&o.bundler!=="unknown")throw new Error(`${o.reason} No files were changed.`);if(o.bundler==="next")O=C("starting the project-local Next.js capture server"),D=await I(l),J=D.url,O.update("capturing shader scenes");else if(o.bundler==="webpack"||o.bundler==="esbuild"||o.bundler==="rollup"){O=C(`building the ${o.bundler} capture target`),await j(l);let N=await P(l);if(N.driverKind!=="static"||N.serve===void 0)throw new Error(`${o.bundler} build completed but no dist/, build/, or out/index.html was found; pass --driver static --serve <directory>.`);T="static",B=N.serve,O.update("capturing shader scenes");}}O??=C("capturing shader scenes"),z=await g({root:l,headed:n.includes("--headed"),ifStale:n.includes("--if-stale"),commitTiming:n.includes("--commit-timing"),...T===void 0?{}:{driverKind:T},...B===void 0?{}:{serve:B},...J===void 0?{}:{url:J},onSceneStart:a$1((o,N,K)=>O?.update(`capturing ${b$1.accent(o)} ${b$1.dim(`(${N+1}/${K})`)}`),"onSceneStart"),onSceneRetry:a$1((o,N,K,re,V)=>{let ae=V instanceof Error&&/timed out/iu.test(V.message),ne=`capture attempt ${N}/${K} for "${o}" after ${ae?`timeout (${Math.round(re/1e3)} s burned)`:`failure (${V instanceof Error?V.message:String(V)})`}`;a.stderr.write(w?`${JSON.stringify({type:"shader-capture-retry",scene:o,attempt:N,total:K,timeoutMs:re,message:ne})}
13
13
  `:`${ne}
14
14
  `);},"onSceneRetry")});}finally{O?.stop(),await D?.close();}if(a.stdout.write(`${w?JSON.stringify(z,null,2):oe(z)}
15
15
  `),!await v(l)){let o="Add registerDevtools({ renderer }) from three-blocks/devtools so committed shader artifacts hydrate in development and production.";a.stderr.write(w?`${JSON.stringify({type:"shader-runtime-registration",state:"missing",message:o})}
16
16
  `:`${c.warn} ${o}
17
- `);}return}if(m==="test"){let g=b("--mode");if(g!==void 0&&g!=="strict")throw new Error('--mode currently supports only "strict".');let{testShaders:W}=await import('./shader-workflow-AAH3FM4U.js'),v=C("verifying precompiled shaders against the live baseline"),U=$("--runs"),j;try{j=await W({root:l,headed:n.includes("--headed"),skipBrowser:n.includes("--skip-browser"),...x===void 0?{}:{driverKind:x},...h===void 0?{}:{serve:h},...k===void 0?{}:{url:k},...U===void 0?{}:{runs:U},parityOnly:n.includes("--parity-only"),commitTiming:n.includes("--commit-timing"),onSceneStart:a$1((I,P,T)=>v.update(`verifying ${b$1.accent(I)} ${b$1.dim(`(${P+1}/${T})`)}`),"onSceneStart")});}finally{v.stop();}a.stdout.write(`${w?JSON.stringify(j,null,2):fe(j)}
18
- `);return}let R=$("--debounce"),{watchShaders:_}=await import('./shader-watch-EI5D7GCN.js'),q=new AbortController;a.once("SIGINT",()=>q.abort()),a.once("SIGTERM",()=>q.abort());let L=await _({root:l,headed:n.includes("--headed"),...x===void 0?{}:{driverKind:x},...h===void 0?{}:{serve:h},...k===void 0?{}:{url:k},...R===void 0?{}:{debounceMs:R},signal:q.signal,onResult(g){a.stdout.write(`${w?JSON.stringify(g):oe(g)}
17
+ `);}return}if(m==="test"){let g=b("--mode");if(g!==void 0&&g!=="strict")throw new Error('--mode currently supports only "strict".');let{testShaders:W}=await import('./shader-workflow-I2RA75GO.js'),v=C("verifying precompiled shaders against the live baseline"),U=$("--runs"),j;try{j=await W({root:l,headed:n.includes("--headed"),skipBrowser:n.includes("--skip-browser"),...x===void 0?{}:{driverKind:x},...h===void 0?{}:{serve:h},...k===void 0?{}:{url:k},...U===void 0?{}:{runs:U},parityOnly:n.includes("--parity-only"),commitTiming:n.includes("--commit-timing"),onSceneStart:a$1((I,P,T)=>v.update(`verifying ${b$1.accent(I)} ${b$1.dim(`(${P+1}/${T})`)}`),"onSceneStart")});}finally{v.stop();}a.stdout.write(`${w?JSON.stringify(j,null,2):fe(j)}
18
+ `);return}let R=$("--debounce"),{watchShaders:_}=await import('./shader-watch-VWJGRJ23.js'),q=new AbortController;a.once("SIGINT",()=>q.abort()),a.once("SIGTERM",()=>q.abort());let L=await _({root:l,headed:n.includes("--headed"),...x===void 0?{}:{driverKind:x},...h===void 0?{}:{serve:h},...k===void 0?{}:{url:k},...R===void 0?{}:{debounceMs:R},signal:q.signal,onResult(g){a.stdout.write(`${w?JSON.stringify(g):oe(g)}
19
19
  `);},onError(g){a.stderr.write(`${w?JSON.stringify({error:g.message}):`${c.cross} ${b$1.danger(g.message)}`}
20
- `);}});w||f(A(c.ring,"watching",b$1.dim(L.root))),await L.done;return}if(y==="text"&&E&&E!=="status"){if(E!=="generate")throw new Error(`Unsupported text command "${E}".`);let{generateTextAtlases:d$1}=await import('./text-atlas-BHPSDU7C.js'),{findProjectRoot:m}=await import('./status-76TXXSRT.js'),M=n.indexOf("--config"),l=M===-1?"three-blocks.text.ts":n[M+1];if(l===void 0||l.startsWith("--"))throw new Error("--config requires a project-relative path.");let S=await m(),x=C("generating MSDF text atlases"),h;try{h=await d$1(S,l);}finally{x.stop();}if(w)a.stdout.write(`${JSON.stringify(h,null,2)}
21
- `);else {f(A(c.tick,"text",`${h.glyphs} glyphs ${c.dot} ${h.atlases.length} atlas${h.atlases.length===1?"":"es"} regenerated`));for(let k of h.updatedFiles)f(` ${d(b$1.dim("updated"),12)} ${b$1.dim(k)}`);}return}if(!["status","text"].includes(y))throw new Error(`Unknown command "${y}".`);let{formatThreeBlocksStatus:e,inspectThreeBlocksStatus:t,threeBlocksStatusIsFresh:i}=await import('./status-76TXXSRT.js'),r=await t(),c$1=(r.text);if(y==="text"&&!c$1)throw new Error("This project does not enable the text feature.");let f$1=y==="text"?c$1:r;a.stdout.write(`${w?JSON.stringify(f$1,null,2):y==="status"?e(r):JSON.stringify(f$1,null,2)}
20
+ `);}});w||f(A(c.ring,"watching",b$1.dim(L.root))),await L.done;return}if(y==="text"&&E&&E!=="status"){if(E!=="generate")throw new Error(`Unsupported text command "${E}".`);let{generateTextAtlases:d$1}=await import('./text-atlas-BHPSDU7C.js'),{findProjectRoot:m}=await import('./status-GATTL2MS.js'),M=n.indexOf("--config"),l=M===-1?"three-blocks.text.ts":n[M+1];if(l===void 0||l.startsWith("--"))throw new Error("--config requires a project-relative path.");let S=await m(),x=C("generating MSDF text atlases"),h;try{h=await d$1(S,l);}finally{x.stop();}if(w)a.stdout.write(`${JSON.stringify(h,null,2)}
21
+ `);else {f(A(c.tick,"text",`${h.glyphs} glyphs ${c.dot} ${h.atlases.length} atlas${h.atlases.length===1?"":"es"} regenerated`));for(let k of h.updatedFiles)f(` ${d(b$1.dim("updated"),12)} ${b$1.dim(k)}`);}return}if(!["status","text"].includes(y))throw new Error(`Unknown command "${y}".`);let{formatThreeBlocksStatus:e,inspectThreeBlocksStatus:t,threeBlocksStatusIsFresh:i}=await import('./status-GATTL2MS.js'),r=await t(),c$1=(r.text);if(y==="text"&&!c$1)throw new Error("This project does not enable the text feature.");let f$1=y==="text"?c$1:r;a.stdout.write(`${w?JSON.stringify(f$1,null,2):y==="status"?e(r):JSON.stringify(f$1,null,2)}
22
22
  `),y==="status"&&n.includes("--check")&&!i(r)&&(a.exitCode=1);}a$1(he,"main");he().catch(e=>{let t=e instanceof Error?e.message:String(e);w?a.stderr.write(`${JSON.stringify({error:t})}
23
23
  `):a.stderr.write(`${c.cross} ${b$1.danger(t)}
24
24
  `),a.exitCode=1;});
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import {c,d,b as b$1}from'./chunk-LZX5NCGL.js';export{a as DOCUMENTED_BROWSER_NOISE,l as createAttachedPlaywrightShaderDriver,j as createPlaywrightShaderDriver,k as createStaticPlaywrightShaderDriver,b as isDocumentedBrowserNoise,i as isRetryableShaderObservationNavigation,c as webgpuBrowserArgs,d as webgpuBrowserHeadless}from'./chunk-LZX5NCGL.js';import {a as a$1,l,d as d$1,f,j,e,i,g,m,h,x,r,s,o,k,c as c$1,G as G$1,v,w,D,u,t,C,N,M as M$1,J,p,L,K,b}from'./chunk-RQEPJ6GC.js';export{o as SHADER_ARTIFACT_DIRECTORY,P as SHADER_CAPTURE_CLIENT_ID,z as SHADER_COMMITTED_TIMING_FILE,w as SHADER_DEVTOOLS_VERSION,y as SHADER_LOCAL_TIMING_FILE,p as SHADER_PARITY_DIRECTORY,A as SHADER_PARITY_EVIDENCE_FILE,x as SHADER_PROVIDER_TRANSFORM_VERSION,n as SHADER_TOOL_CONFIG_FILE,S as applyShaderProviderTransform,U as assertShaderProviderTransform,T as createShaderProviderTransform,u as ensureShaderToolConfig,r as findShaderProjectRoot,t as inferShaderCaptureTarget,O as loadShaderCaptureRuntimeSource,s as loadShaderToolConfig,b as parseProjectMetadata,c as parseShaderReceipt,q as parseShaderToolConfig,I as readShaderCommittedTiming,F as readShaderLocalTiming,H as readShaderParityEvidence,G as readShaderTiming,E as serializeShaderManifest,B as shaderCoverage,D as stableStringify,C as validateShaderCapture,N as writeShaderArtifacts,J as writeShaderLocalTiming,K as writeShaderParityEvidence,M as writeShaderTimingTwins}from'./chunk-RQEPJ6GC.js';export{b as compareShaderScreenshots,a as shaderScreenshotMetrics}from'./chunk-UDUICSME.js';import {a}from'./chunk-EI7MMDWY.js';import {rm,mkdir,writeFile,rename,realpath,readdir,readFile,lstat}from'fs/promises';import z from'path';import {createRequire}from'module';import {createHash,randomUUID}from'crypto';import Mt,{platform,homedir}from'os';import {fileURLToPath}from'url';import*as at from'zlib';import at__default from'zlib';import {createDefaultContainer,VK_FORMAT_R8G8B8A8_UNORM,KHR_SUPERCOMPRESSION_ZSTD,KHR_SUPERCOMPRESSION_NONE,KHR_DF_FLAG_ALPHA_STRAIGHT,KHR_DF_TRANSFER_LINEAR,KHR_DF_PRIMARIES_BT709,KHR_DF_MODEL_RGBSDA,KHR_DF_VERSION,KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT,KHR_DF_VENDORID_KHRONOS,KHR_DF_CHANNEL_RGBSDA_RED,KHR_DF_CHANNEL_RGBSDA_GREEN,KHR_DF_CHANNEL_RGBSDA_BLUE,KHR_DF_CHANNEL_RGBSDA_ALPHA,KHR_DF_SAMPLE_DATATYPE_LINEAR,write,read,VK_FORMAT_R16G16B16A16_SFLOAT}from'ktx-parse';import ys from'msdf-bmfont-xml';import qr from'opentype.js';import {PNG}from'pngjs';import {SHADER_ADDRESS_SCHEMA_VERSION,SHADER_RECIPE_SCHEMA_VERSION,SHADER_HYDRATION_SCHEMA_VERSION}from'three-blocks/shaders';import {watch}from'fs';var Ar=4096,Eo=createRequire(import.meta.url),Cr,W=new Proxy({},{get(e,t){return Cr??=Eo("typescript"),Reflect.get(Cr,t)}});function ve(e){let t=e;for(;W.isParenthesizedExpression(t)||W.isAsExpression(t)||W.isSatisfiesExpression(t)||W.isNonNullExpression(t);)t=t.expression;return t}a(ve,"unwrap");function To(e){if(W.isIdentifier(e)||W.isStringLiteral(e)||W.isNumericLiteral(e))return e.text}a(To,"propertyName");function kt(e,t){let r=new Map;for(let n of e.properties){if(!W.isPropertyAssignment(n))throw new Error(`${t} may contain only static property assignments.`);let o=To(n.name);if(o===void 0||r.has(o))throw new Error(`${t} contains a computed or duplicate property.`);r.set(o,n.initializer);}return r}a(kt,"properties");function xt(e,t){if(e===void 0)throw new Error(`${t} is missing.`);let r=ve(e);if(!W.isObjectLiteralExpression(r))throw new Error(`${t} must be a static object literal.`);return r}a(xt,"objectLiteral");function Rt(e,t){if(e===void 0)throw new Error(`${t} is missing.`);let r=ve(e);if(!W.isStringLiteral(r)&&!W.isNoSubstitutionTemplateLiteral(r))throw new Error(`${t} must be a string literal.`);return r.text}a(Rt,"stringLiteral");function vt(e,t){if(e===void 0)throw new Error(`${t} is missing.`);let r=ve(e);if(!W.isNumericLiteral(r))throw new Error(`${t} must be a numeric literal.`);return Number(r.text)}a(vt,"numericLiteral");function Mr(e,t){if(e===void 0)throw new Error(`${t} is missing.`);let r=ve(e);if(!W.isArrayLiteralExpression(r))throw new Error(`${t} must be a static array literal.`);return r.elements}a(Mr,"arrayLiteral");function Bo(e,t){if(e===void 0)throw new Error(`${t} is missing.`);let r=ve(e);if(r.kind===W.SyntaxKind.NullKeyword)return null;if(!W.isNumericLiteral(r))throw new Error(`${t} must be null or a numeric literal.`);return Number(r.text)}a(Bo,"numericOrNullLiteral");function Po(e){return e.parseDiagnostics??[]}a(Po,"parseDiagnostics");function Et(e,t,r,n){let o=W.createSourceFile(t,e,W.ScriptTarget.Latest,true,W.ScriptKind.TS),s=Po(o);if(s.length>0)throw new Error(`Shader manifest is not valid TypeScript: ${W.flattenDiagnosticMessageText(s[0]?.messageText??"parse error"," ")}`);let a$1=o.statements.filter(W.isExportAssignment).filter(f=>!f.isExportEquals);if(a$1.length!==1)throw new Error("Shader manifest must contain exactly one default export.");let i=kt(xt(a$1[0]?.expression,"Shader manifest default export"),"Shader manifest"),c=i.get("version");if(c===void 0||!W.isNumericLiteral(ve(c))||Number(ve(c).getText(o))!==3)throw new Error("Shader manifest version must be the numeric literal 3.");if(Rt(i.get("scene"),"Shader manifest scene")!==r)throw new Error(`Shader manifest scene does not match "${r}".`);if(n){if(Rt(i.get("three"),"Shader manifest Three.js version")!==n.three||Rt(i.get("threeBlocks"),"Shader manifest Three Blocks version")!==n.threeBlocks)throw new Error("Shader manifest runtime versions do not match its receipt.");let f=kt(xt(i.get("runtime"),"Shader manifest runtime"),"Shader manifest runtime");if(Rt(f.get("id"),"Shader manifest runtime id")!==n.compatibility||vt(f.get("address"),"Shader manifest address schema")!==n.address||vt(f.get("recipe"),"Shader manifest recipe schema")!==n.recipe||vt(f.get("hydration"),"Shader manifest hydration schema")!==n.hydration)throw new Error("Shader manifest runtime compatibility schemas do not match its receipt.")}let u=kt(xt(i.get("entries"),"Shader manifest entries"),"Shader manifest entries");if(u.size===0||u.size>Ar)throw new Error(`Shader manifest must contain between 1 and ${Ar} entries.`);let p=Mr(i.get("modules"),"Shader manifest modules").map((f,h)=>{let y=ve(f);if(!W.isStringLiteral(y)&&!W.isNoSubstitutionTemplateLiteral(y))throw new Error(`Shader manifest module ${h} must be a WGSL string literal.`);if(y.text.length===0)throw new Error(`Shader manifest module ${h} is empty.`);return y.text}),l=Mr(i.get("states"),"Shader manifest states").map((f,h)=>{let y=kt(xt(f,`Shader manifest state ${h}`),`Shader manifest state ${h}`),b=a((A,C)=>{let K=Bo(y.get(A),`Shader manifest state ${h} ${A}`);if(K===null)return false;let S=p[K];if(S===void 0||!S.includes(C))throw new Error(`Shader manifest state ${h} ${A} does not reference a ${C} module.`);return true},"moduleAt"),x=b("vertex","@vertex"),R=b("fragment","@fragment"),w=b("compute","@compute");if(w&&(x||R))throw new Error(`Shader manifest state ${h} mixes render and compute stages.`);if(!w&&!x&&!R)throw new Error(`Shader manifest state ${h} contains no shader stage.`);return {vertex:x,fragment:R,compute:w}}),m={render:0,vertex:0,fragment:0,compute:0};for(let[f,h]of u){if(f.length===0||/[\u0000-\u001f\u007f]/.test(f))throw new Error("Shader manifest contains an invalid entry key.");let y=vt(h,`Shader manifest entry "${f}"`),b=l[y];if(b===void 0)throw new Error(`Shader manifest entry "${f}" references an absent state.`);(b.vertex||b.fragment)&&(m.render+=1),b.vertex&&(m.vertex+=1),b.fragment&&(m.fragment+=1),b.compute&&(m.compute+=1);}return m}a(Et,"inspectPrecompiledManifest");var Ao=createRequire(import.meta.url),Fr,G=new Proxy({},{get(e,t){return Fr??=Ao("typescript"),Reflect.get(Fr,t)}}),Co=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Mo=new Set(["script","style","template"]),Or=2e5,Fo={amp:"&",apos:"'",copy:"\xA9",deg:"\xB0",gt:">",hellip:"\u2026",ldquo:"\u201C",lsquo:"\u2018",lt:"<",mdash:"\u2014",nbsp:"\xA0",ndash:"\u2013",quot:'"',rdquo:"\u201D",rsquo:"\u2019"};function Oo(e){return e.replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z][a-z0-9]+);/giu,(t,r)=>{if(r.startsWith("#x")||r.startsWith("#X")){let n=Number.parseInt(r.slice(2),16);return nt(n)?String.fromCodePoint(n):t}if(r.startsWith("#")){let n=Number.parseInt(r.slice(1),10);return nt(n)?String.fromCodePoint(n):t}return Fo[r.toLowerCase()]??t})}a(Oo,"decodeHtmlEntities");function nt(e){return Number.isSafeInteger(e)&&e>=0&&e<=1114111&&!(e>=55296&&e<=57343)}a(nt,"validCodePoint");function Lr(e){return nt(e)&&e>=32&&!(e>=127&&e<=159)}a(Lr,"renderableCodePoint");function Io(e){return /(?:^|\s)data-canvas-text(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?(?=\s|\/?>)/iu.test(e)}a(Io,"hasCanvasTextAttribute");function Kt(e){let t=[],r=[],n=e.match(/<!--[\s\S]*?-->|<![^>]*>|<[^>]*>|[^<]+/gu)??[];for(let o of n){if(!o.startsWith("<")){if(r.some(c=>c.synchronized)&&!r.some(c=>c.skipped)){let c=Oo(o);c.trim().length>0&&t.push(c);}continue}if(o.startsWith("<!--")||o.startsWith("<!")||o.startsWith("<?"))continue;let s=/^<\s*\//u.test(o),a=/^<\s*\/?\s*([a-z][a-z0-9:-]*)/iu.exec(o)?.[1]?.toLowerCase();if(!a)continue;if(s){let c=r.map(u=>u.tag).lastIndexOf(a);c>=0&&r.splice(c);continue}/\/\s*>$/u.test(o)||Co.has(a)||r.push({tag:a,synchronized:Io(o),skipped:Mo.has(a)});}return t}a(Kt,"extractCanvasTextFromHtml");function Lo(e){let t=new Set,r=new Set;for(let n of e.statements){if(!G.isImportDeclaration(n)||!G.isStringLiteral(n.moduleSpecifier)||n.moduleSpecifier.text!=="three-blocks/text")continue;let o=n.importClause?.namedBindings;if(o&&G.isNamespaceImport(o)&&r.add(o.name.text),o&&G.isNamedImports(o))for(let s of o.elements)(s.propertyName?.text??s.name.text)==="defineTextContent"&&t.add(s.name.text);}return {named:t,namespaces:r}}a(Lo,"importedTextHelpers");function jo(e,t){return G.isIdentifier(e)?t.named.has(e.text):G.isPropertyAccessExpression(e)&&G.isIdentifier(e.expression)&&t.namespaces.has(e.expression.text)&&e.name.text==="defineTextContent"}a(jo,"isDefineTextContentCall");function No(e){let t=e;for(;G.isParenthesizedExpression(t)||G.isAsExpression(t)||G.isSatisfiesExpression(t)||G.isTypeAssertionExpression(t);)t=t.expression;return t}a(No,"unwrapExpression");function zt(e,t,r){let n=No(e);if(G.isStringLiteral(n)||G.isNoSubstitutionTemplateLiteral(n)){t.push(n.text);return}if(G.isArrayLiteralExpression(n)){for(let a of n.elements){if(G.isSpreadElement(a))throw new Error(`${r}: defineTextContent() cannot use spread elements.`);zt(a,t,r);}return}if(G.isObjectLiteralExpression(n)){for(let a of n.properties){if(!G.isPropertyAssignment(a))throw new Error(`${r}: defineTextContent() accepts only static property assignments.`);zt(a.initializer,t,r);}return}let o=n.getStart(),s=n.getSourceFile().getLineAndCharacterOfPosition(o).line+1;throw new Error(`${r}:${s}: defineTextContent() contains dynamic text; declare a Unicode range or an explicit static string.`)}a(zt,"collectStaticStrings");function qt(e,t="content.ts"){let r=G.createSourceFile(t,e,G.ScriptTarget.Latest,true,t.endsWith(".tsx")?G.ScriptKind.TSX:G.ScriptKind.TS),n=Lo(r),o=[];function s(a){if(G.isCallExpression(a)&&jo(a.expression,n)){if(a.arguments.length!==1||!a.arguments[0])throw new Error(`${t}: defineTextContent() requires exactly one static argument.`);zt(a.arguments[0],o,t);return}G.forEachChild(a,s);}return a(s,"visit"),s(r),o}a(qt,"extractDefinedTextContent");function Do(e){let t=[];if(e==="latin"){for(let r=32;r<=126;r++)t.push(r);for(let r of "\u2018\u2019\u201C\u201D\u2013\u2014\u2026\u2022\xB7\xAB\xBB\u2039\u203A\u20AC\xA3\xA5\xB0\xB1\xD7\xF7\xA9\xAE\u2122\xA0"){let n=r.codePointAt(0);n!==void 0&&t.push(n);}}else {for(let r=12353;r<=12438;r++)t.push(r);for(let r=12443;r<=12447;r++)t.push(r);for(let r=12448;r<=12543;r++)t.push(r);for(let r of "\u3000\u3001\u3002\u300C\u300D\u300E\u300F\uFF08\uFF09\u30FB\u30FC\u301C\u3008\u3009\u300A\u300B\u3010\u3011\uFF01\uFF1F\uFF1A\uFF1B\uFF10\uFF11\uFF12\uFF13\uFF14\uFF15\uFF16\uFF17\uFF18\uFF19\uFF05\uFF06"){let n=r.codePointAt(0);n!==void 0&&t.push(n);}}return t}a(Do,"presetCodePoints");function Ir(e,t){for(let r of t.normalize("NFC")){let n=r.codePointAt(0);n!==void 0&&Lr(n)&&e.add(n);}}a(Ir,"addCharacters");function Xt(e,t={}){let r=new Set;for(let i of e)Ir(r,i);t.additionalCharacters&&Ir(r,t.additionalCharacters);for(let i of t.presets??[])for(let c of Do(i))r.add(c);let n=0;for(let i of t.ranges??[]){if(!nt(i.start)||!nt(i.end)||i.end<i.start)throw new RangeError("Text Unicode ranges must contain ordered Unicode scalar values.");if(n+=i.end-i.start+1,n>Or)throw new RangeError(`Configured Unicode ranges exceed the ${Or}-code-point safety limit.`);for(let c=i.start;c<=i.end;c++)Lr(c)&&r.add(c);}r.add(32),r.add(63),r.add(65533);let o=[...r].sort((i,c)=>i-c),s=o.map(i=>String.fromCodePoint(i)).join(""),a=createHash("sha256").update(s.normalize("NFC")).digest("hex");return {codePoints:o,characters:s,hash:a}}a(Xt,"buildGlyphSet");var Vo=createRequire(import.meta.url),jr,M=new Proxy({},{get(e,t){return jr??=Vo("typescript"),Reflect.get(jr,t)}});function Uo(e){let t=e;for(;M.isParenthesizedExpression(t)||M.isAsExpression(t)||M.isSatisfiesExpression(t)||M.isTypeAssertionExpression(t);)t=t.expression;return t}a(Uo,"unwrap");function Wo(e,t){if(M.isIdentifier(e)||M.isStringLiteral(e)||M.isNumericLiteral(e))return e.text;throw new Error(`${t}: text configuration property names must be static.`)}a(Wo,"propertyName");function Tt(e,t){let r=Uo(e);if(M.isStringLiteral(r)||M.isNoSubstitutionTemplateLiteral(r))return r.text;if(M.isNumericLiteral(r))return Number(r.text);if(r.kind===M.SyntaxKind.TrueKeyword)return true;if(r.kind===M.SyntaxKind.FalseKeyword)return false;if(r.kind===M.SyntaxKind.NullKeyword)return null;if(M.isPrefixUnaryExpression(r)&&(r.operator===M.SyntaxKind.MinusToken||r.operator===M.SyntaxKind.PlusToken)){let o=Tt(r.operand,t);if(typeof o=="number")return r.operator===M.SyntaxKind.MinusToken?-o:o}if(M.isArrayLiteralExpression(r))return r.elements.map(o=>{if(M.isSpreadElement(o))throw new Error(`${t}: text configuration cannot use spread elements.`);return Tt(o,t)});if(M.isObjectLiteralExpression(r)){let o=Object.create(null);for(let s of r.properties){if(!M.isPropertyAssignment(s))throw new Error(`${t}: text configuration accepts only static property assignments.`);let a=Wo(s.name,t);if(Object.hasOwn(o,a))throw new Error(`${t}: duplicate text configuration property "${a}".`);o[a]=Tt(s.initializer,t);}return o}let n=r.getSourceFile().getLineAndCharacterOfPosition(r.getStart()).line+1;throw new Error(`${t}:${n}: text configuration must be statically inspectable.`)}a(Tt,"evaluateStatic");function Go(e){let t=new Set,r=new Set;for(let n of e.statements){if(!M.isImportDeclaration(n)||!M.isStringLiteral(n.moduleSpecifier)||n.moduleSpecifier.text!=="three-blocks/text")continue;let o=n.importClause?.namedBindings;if(o&&M.isNamespaceImport(o)&&r.add(o.name.text),o&&M.isNamedImports(o))for(let s of o.elements)(s.propertyName?.text??s.name.text)==="defineText"&&t.add(s.name.text);}return {named:t,namespaces:r}}a(Go,"helperNames");function zo(e,t){return M.isIdentifier(e)?t.named.has(e.text):M.isPropertyAccessExpression(e)&&M.isIdentifier(e.expression)&&t.namespaces.has(e.expression.text)&&e.name.text==="defineText"}a(zo,"isDefineTextCall");function ge(e,t){if(typeof e!="string"||e.trim().length===0)throw new Error(`${t} must be a non-empty string.`);return e}a(ge,"requiredString");function Bt(e,t,r=false){if(!Array.isArray(e)||!r&&e.length===0)throw new Error(`${t} must be ${r?"an":"a non-empty"} array of strings.`);return e.map((n,o)=>ge(n,`${t}[${o}]`))}a(Bt,"stringArray");function Pt(e,t){if(e.includes("\\")||z.posix.isAbsolute(e)||z.posix.normalize(e)!==e||e===".."||e.startsWith("../")||/[\u0000-\u001f\u007f]/u.test(e))throw new Error(`${t} must be a safe project-relative path.`);return e}a(Pt,"safeProjectPath");function Ko(e,t){if(!a$1(e))throw new Error(`${t} must be an object.`);let r=Object.keys(e).sort();if(r.length===1&&r[0]==="builtin")return {builtin:ge(e.builtin,`${t}.builtin`)};if(r.length===1&&r[0]==="path")return {path:Pt(ge(e.path,`${t}.path`),`${t}.path`)};if(r.join(",")==="checksum,file,package")return {package:ge(e.package,`${t}.package`),file:Pt(ge(e.file,`${t}.file`),`${t}.file`),checksum:ge(e.checksum,`${t}.checksum`)};throw new Error(`${t} must select exactly one supported source.`)}a(Ko,"parseFontSource");function Jt(e,t){let r=ge(e,t);if(r.includes("\\")||/[\u0000-\u001f\u007f]/u.test(r)||r.split("/").includes(".."))throw new Error(`${t} is unsafe.`);return r}a(Jt,"deployedPath");function qo(e){if(e===void 0)return {};if(!a$1(e))throw new Error("Text generation options must be an object.");let t=e.presets===void 0?void 0:Bt(e.presets,"Text generation presets",true).map(c=>{if(c!=="latin"&&c!=="japanese-kana")throw new Error(`Unsupported text preset "${c}".`);return c}),r;if(e.ranges!==void 0){if(!Array.isArray(e.ranges))throw new Error("Text generation ranges must be an array.");r=e.ranges.map((c,u)=>{if(!a$1(c)||typeof c.start!="number"||typeof c.end!="number")throw new Error(`Text generation range ${u} is invalid.`);return {start:c.start,end:c.end}});}let n=a(c=>{let u=e[c];if(u!==void 0){if(typeof u!="number"||!Number.isFinite(u))throw new Error(`Text generation ${c} must be finite.`);return u}},"numeric"),o=n("size"),s=n("distanceRange"),a$2=n("padding"),i=n("maxTextureSize");return {...t===void 0?{}:{presets:t},...r===void 0?{}:{ranges:r},...e.additionalCharacters===void 0?{}:{additionalCharacters:ge(e.additionalCharacters,"Text generation additionalCharacters")},...o===void 0?{}:{size:o},...s===void 0?{}:{distanceRange:s},...a$2===void 0?{}:{padding:a$2},...i===void 0?{}:{maxTextureSize:i}}}a(qo,"parseGeneration");function Xo(e){if(!a$1(e)||e.schemaVersion!==void 0&&e.schemaVersion!==1)throw new Error("Text configuration must use schemaVersion 1.");let t=Bt(e.content,"Text content inputs").map(o=>Pt(o,"Text content input"));if(!a$1(e.fonts)||Object.keys(e.fonts).length===0)throw new Error("Text fonts must be a non-empty object.");let r={},n=0;for(let[o,s]of Object.entries(e.fonts)){if(ge(o,"Text font key"),!a$1(s))throw new Error(`Text font "${o}" must be an object.`);let a=s.default===true;a&&n++,r[o]={source:Ko(s.source,`Text font "${o}" source`),browser:Jt(s.browser,`Text font "${o}" browser path`),atlas:Jt(s.atlas,`Text font "${o}" atlas path`),metrics:Jt(s.metrics,`Text font "${o}" metrics path`),families:Bt(s.families,`Text font "${o}" families`),languages:s.languages===void 0?[]:Bt(s.languages,`Text font "${o}" languages`,true),default:a};}if(Object.keys(r).length>1&&n!==1)throw new Error("Multiple text fonts require exactly one default route.");if(n>1)throw new Error("Text fonts can select only one default route.");return {schemaVersion:1,content:t,fonts:r,generation:qo(e.generation)}}a(Xo,"validateConfiguration");function Nr(e,t="three-blocks.text.ts"){let r=M.createSourceFile(t,e,M.ScriptTarget.Latest,true,M.ScriptKind.TS),n=Go(r),o=[];function s(a){if(M.isCallExpression(a)&&zo(a.expression,n)){if(a.arguments.length!==1||!a.arguments[0])throw new Error(`${t}: defineText() requires one static argument.`);o.push(Tt(a.arguments[0],t));return}M.forEachChild(a,s);}if(a(s,"visit"),s(r),o.length!==1)throw new Error(`${t} must contain exactly one imported defineText() call.`);return Xo(o[0])}a(Nr,"parseTextConfiguration");function Zt(e,t){if(typeof e=="string")t.push(e);else if(Array.isArray(e))for(let r of e)Zt(r,t);else if(a$1(e))for(let r of Object.values(e))Zt(r,t);}a(Zt,"jsonStrings");async function $t(e,t="three-blocks.text.ts"){let r=Pt(t,"Text configuration path"),n=await l(e,z.join(e,r),d$1.semanticInput,"Text configuration");return Nr(n.data.toString("utf8"),r)}a($t,"readTextConfiguration");async function _t(e,t){let r=[],n={},o=0;for(let s of t.content){let a=await l(e,z.join(e,s),d$1.semanticInput,"Text content input");if(o+=a.data.byteLength,o>d$1.semanticTotal)throw new Error("Text content inputs exceed the total inspection size limit.");n[s]=f(a.data);let i=a.data.toString("utf8"),c=z.extname(s).toLowerCase();if(c===".html"||c===".htm")r.push(...Kt(i));else if([".ts",".tsx",".js",".jsx",".mts",".cts",".mjs",".cjs"].includes(c))r.push(...qt(i,s));else if(c===".json")Zt(JSON.parse(i),r);else if(c===".txt"||c===".md")r.push(i);else throw new Error(`Unsupported configured text content type: ${s}.`)}return {values:r,glyphs:Xt(r,t.generation),inputs:n}}a(_t,"discoverTextContent");var or=1,it="1.0.0",ws=Object.freeze({"geist-sans":{id:"geist-sans",family:"Geist Sans",version:"1.600",license:"OFL-1.1",licenseFile:"OFL-1.1.txt",sourceFile:"geist-sans/Geist-Variable.ttf",sourceUrl:"https://raw.githubusercontent.com/vercel/geist-font/1.6.0/fonts/Geist/variable/Geist%5Bwght%5D.ttf",sourceBytes:168472,sourceChecksum:"995c579489b33cd28a6732d7aa7ca1b46c2faa832c18b4063933d7652c39932b",browserFile:"geist-sans/Geist-Variable.woff2",browserUrl:"https://raw.githubusercontent.com/vercel/geist-font/449415077ee4ffc191b4e7e557cd35e88b1b98fd/packages/next/dist/fonts/geist-sans/Geist-Variable.woff2",browserBytes:58512,browserChecksum:"46525b05bbf4527d263f8624ca7024c7d0dce3c64430267d30c31c6dd3821e4d"},"noto-sans-jp":{id:"noto-sans-jp",family:"Noto Sans JP",version:"2.004-H2",license:"OFL-1.1",licenseFile:"OFL-1.1.txt",sourceFile:"noto-sans-jp/NotoSansJP[wght].ttf",sourceUrl:"https://raw.githubusercontent.com/google/fonts/295d98a7a0c17c68f1341eaeea354e7960ea70d3/ofl/notosansjp/NotoSansJP%5Bwght%5D.ttf",sourceBytes:9589900,sourceChecksum:"c2f3b4d463500a2ddcd3849cded1fceeb9fd6d1c32e6cbecd568453ba50fc68f",browserFile:"noto-sans-jp/NotoSansJP[wght].woff2",browserUrl:"https://raw.githubusercontent.com/RenaudRohlinger/three-blocks-monorepo/364a50cc5f6f92735a110b50144e8d62404c9d87/packages/three-blocks-devtools/fonts/noto-sans-jp/NotoSansJP%5Bwght%5D.woff2",browserBytes:4350080,browserChecksum:"6fd94964d1990baa2a392cea7a036683d2b80b9dfd590cb3918e8dab98d8e188"}}),bs="THREE_BLOCKS_FONT_CACHE_DIR",Ss=6e4,At=new Map,ks=fileURLToPath(new URL("../fonts/",import.meta.url));function ae(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} must be finite.`);return e}a(ae,"finiteNumber");function Ee(e,t){let r=ae(e,t);if(!Number.isSafeInteger(r))throw new Error(`${t} must be an integer.`);return r}a(Ee,"integer");function xs(e){if(!a$1(e)||!a$1(e.info)||!a$1(e.common)||!Array.isArray(e.chars))throw new Error("MSDF generator returned invalid BMFont metadata.");let t=e.chars.map((o,s)=>{if(!a$1(o))throw new Error(`BMFont character ${s} is invalid.`);return {id:Ee(o.id,`BMFont character ${s}.id`),x:ae(o.x,`BMFont character ${s}.x`),y:ae(o.y,`BMFont character ${s}.y`),width:ae(o.width,`BMFont character ${s}.width`),height:ae(o.height,`BMFont character ${s}.height`),xoffset:ae(o.xoffset,`BMFont character ${s}.xoffset`),yoffset:ae(o.yoffset,`BMFont character ${s}.yoffset`),xadvance:ae(o.xadvance,`BMFont character ${s}.xadvance`)}}),r=e.kernings===void 0?[]:e.kernings;if(!Array.isArray(r))throw new Error("BMFont kernings are invalid.");let n=r.map((o,s)=>{if(!a$1(o))throw new Error(`BMFont kerning ${s} is invalid.`);return {first:Ee(o.first,`BMFont kerning ${s}.first`),second:Ee(o.second,`BMFont kerning ${s}.second`),amount:ae(o.amount,`BMFont kerning ${s}.amount`)}});return {info:{size:ae(e.info.size,"BMFont info.size"),face:typeof e.info.face=="string"?e.info.face:"Font"},common:{base:ae(e.common.base,"BMFont common.base"),scaleW:Ee(e.common.scaleW,"BMFont common.scaleW"),scaleH:Ee(e.common.scaleH,"BMFont common.scaleH")},chars:t,kernings:n}}a(xs,"parseBMFont");function Xr(e){let t=e.generation.size??48,r=e.generation.distanceRange??8,n=e.generation.padding??2,o=e.generation.maxTextureSize??4096;if(!Number.isInteger(t)||t<8||t>256)throw new Error("Text generation size must be an integer from 8 to 256.");if(!Number.isInteger(r)||r<1||r>64)throw new Error("Text generation distanceRange must be an integer from 1 to 64.");if(!Number.isInteger(n)||n<0||n>32)throw new Error("Text generation padding must be an integer from 0 to 32.");if(!Number.isInteger(o)||o<64||o>8192||(o&o-1)!==0)throw new Error("Text generation maxTextureSize must be a power of two from 64 to 8192.");return {size:t,distanceRange:r,padding:n,maxTextureSize:o}}a(Xr,"atlasOptions");function sr(e){let t=ws[e];if(t===void 0)throw new Error(`Unknown built-in font ${JSON.stringify(e)}.`);return t}a(sr,"builtinFontMetadata");function Jr(e){let t=e.cacheDirectory??process.env[bs];return t?z.resolve(t):platform()==="darwin"?z.join(homedir(),"Library","Caches","three-blocks","fonts"):platform()==="win32"?z.join(process.env.LOCALAPPDATA?.trim()||z.join(homedir(),"AppData","Local"),"Three Blocks","Cache","fonts"):z.join(process.env.XDG_CACHE_HOME?.trim()||z.join(homedir(),".cache"),"three-blocks","fonts")}a(Jr,"fontCacheRoot");function Hr(e,t){return t==="source"?{font:e,kind:t,file:e.sourceFile,url:e.sourceUrl,bytes:e.sourceBytes,checksum:e.sourceChecksum,...e.sourceArchive===void 0?{}:{archive:e.sourceArchive}}:{font:e,kind:t,file:e.browserFile,url:e.browserUrl,bytes:e.browserBytes,checksum:e.browserChecksum}}a(Hr,"builtinAsset");function Zr(e,t){let r=sr(e),n=t.mapBuiltinFont?.(r)??r;if(n.id!==r.id||n.version!==r.version||n.sourceBytes!==r.sourceBytes||n.sourceChecksum!==r.sourceChecksum||n.browserBytes!==r.browserBytes||n.browserChecksum!==r.browserChecksum)throw new Error(`Runtime metadata for built-in font ${JSON.stringify(e)} changed its pinned identity.`);return n}a(Zr,"runtimeBuiltinFontMetadata");function Rs(e,t){return z.join(Jr(t),e.font.id,e.font.version,e.checksum,z.basename(e.file))}a(Rs,"builtinCachePath");async function vs(e$1,t){try{let r=await j(e$1,d$1.texture,`${t.font.id} cached ${t.kind} font`);if(r.data.byteLength===t.bytes&&f(r.data)===t.checksum)return r.data;await rm(e$1,{force:!0});return}catch(r){if(e(r)==="ENOENT")return;throw r}}a(vs,"readCachedFont");async function Es(e$1){try{let t=await j(z.join(ks,e$1.file),e$1.bytes,`${e$1.font.id} packaged ${e$1.kind} font`);return t.data.byteLength===e$1.bytes&&f(t.data)===e$1.checksum?t.data:void 0}catch(t){if(e(t)==="ENOENT")return;throw t}}a(Es,"readPackagedFont");async function Ts(e,t){try{let r=await l(e.root,e.filePath,t.bytes,`${t.font.id} existing browser font output`);return r.data.byteLength!==t.bytes||f(r.data)!==t.checksum?void 0:r.data}catch{return}}a(Ts,"readBuiltinBrowserSeed");function Bs(e,t,r){let n=Math.max(0,e.byteLength-65557),o=-1;for(let u=e.byteLength-22;u>=n;u--)if(e.readUInt32LE(u)===101010256){o=u;break}if(o<0)throw new Error("downloaded ZIP has no end-of-central-directory record");let s=e.readUInt16LE(o+10),a=e.readUInt32LE(o+12),i=e.readUInt32LE(o+16);if(i+a>o)throw new Error("downloaded ZIP central directory is out of bounds");let c=i;for(let u=0;u<s;u++){if(c+46>e.byteLength||e.readUInt32LE(c)!==33639248)throw new Error("downloaded ZIP central directory is invalid");let p=e.readUInt16LE(c+10),l=e.readUInt32LE(c+20),m=e.readUInt32LE(c+24),f=e.readUInt16LE(c+28),h=e.readUInt16LE(c+30),y=e.readUInt16LE(c+32),b=e.readUInt32LE(c+42),x=c+46+f+h+y;if(x>e.byteLength)throw new Error("downloaded ZIP entry metadata is out of bounds");let R=e.subarray(c+46,c+46+f).toString("utf8");if(c=x,R!==t)continue;if(m!==r)throw new Error(`ZIP entry has ${m} bytes; expected ${r}`);if(b+30>e.byteLength||e.readUInt32LE(b)!==67324752)throw new Error("downloaded ZIP local entry is invalid");let w=e.readUInt16LE(b+26),A=e.readUInt16LE(b+28),C=b+30+w+A;if(C+l>e.byteLength)throw new Error("downloaded ZIP entry data is out of bounds");let K=e.subarray(C,C+l);if(p===0)return Buffer.from(K);if(p===8)return at.inflateRawSync(K,{maxOutputLength:r});throw new Error(`ZIP entry uses unsupported compression method ${p}`)}throw new Error(`downloaded ZIP does not contain ${JSON.stringify(t)}`)}a(Bs,"zipEntry");async function Ps(e,t){let r=new URL(e.url);if(r.protocol!=="https:")throw new Error(`Built-in font source must use HTTPS: ${e.url}.`);let n;try{n=await t(r,{signal:AbortSignal.timeout(Ss)});}catch(h){throw new Error(`request failed: ${h instanceof Error?h.message:String(h)}`,{cause:h})}if(!n.ok)throw new Error(`server returned HTTP ${n.status} ${n.statusText}`.trim());let o=e.archive?.bytes??e.bytes,s=e.archive?.checksum??e.checksum,a=n.headers.get("content-length");if(a!==null){let h=Number(a);if(!Number.isSafeInteger(h)||h!==o)throw new Error(`server declared ${a} bytes; expected ${o}`)}if(n.body===null)throw new Error("server returned an empty response body");let i=n.body.getReader(),c=[],u=0;for(;;){let h=await i.read();if(h.done)break;if(u+=h.value.byteLength,u>o||u>d$1.texture)throw await i.cancel(),new Error(`download exceeded the expected ${o}-byte size`);c.push(Buffer.from(h.value.buffer,h.value.byteOffset,h.value.byteLength));}let p=Buffer.concat(c,u);if(p.byteLength!==o)throw new Error(`downloaded ${p.byteLength} bytes; expected ${o}`);let l=f(p);if(l!==s)throw new Error(`checksum mismatch: expected ${s}, received ${l}`);let m=e.archive===void 0?p:Bs(p,e.archive.entry,e.bytes);if(m.byteLength!==e.bytes)throw new Error(`resolved ${m.byteLength} bytes; expected ${e.bytes}`);let f$1=f(m);if(f$1!==e.checksum)throw new Error(`resolved checksum mismatch: expected ${e.checksum}, received ${f$1}`);return m}a(Ps,"downloadFont");async function Qt(e,t){await mkdir(z.dirname(e),{recursive:true});let r=`${e}.${process.pid}.${randomUUID()}.tmp`;try{await writeFile(r,t,{flag:"wx"}),await rename(r,e);}finally{await rm(r,{force:true});}}a(Qt,"writeCachedFont");async function Vr(e,t,r){let n=Rs(e,t),o=At.get(n);if(o)return o;let s=(async()=>{let a=await vs(n,e);if(a)return a;if(t.fetch===void 0&&t.mapBuiltinFont===void 0){let i=await Es(e);if(i!==void 0)return await Qt(n,i),i}if(r!==void 0){let i=await Ts(r,e);if(i!==void 0)return await Qt(n,i),i}try{let i=await Ps(e,t.fetch??globalThis.fetch);return await Qt(n,i),i}catch(i){throw new Error(`Could not download the built-in ${e.font.id} ${e.kind} font from ${e.url}: ${i instanceof Error?i.message:String(i)}. Connect once to prewarm the checksum-keyed cache at ${JSON.stringify(Jr(t))}, or configure source.path/source.package for fully offline text generation.`,{cause:i})}})();At.set(n,s);try{return await s}finally{At.get(n)===s&&At.delete(n);}}a(Vr,"cachedBuiltinAsset");async function Yr(e,t,r){let[n,o]=await Promise.allSettled([Vr(Hr(e,"source"),t),Vr(Hr(e,"browser"),t,r)]);if(n.status==="rejected")throw n.reason;if(o.status==="rejected")throw o.reason;return [n.value,o.value]}a(Yr,"cachedBuiltinPair");async function $s(e,t={}){let r=Zr(e,t);await Yr(r,t);}a($s,"prewarmBuiltinFont");async function Qr(e,t,r){let n=await j(e,d$1.texture,r),o=f(n.data);if(t!=="pending"&&o!==t)throw new Error(`${r} checksum mismatch: expected ${t}, received ${o}.`);return n.data}a(Qr,"checkedExternalFile");function en(e,t){if(!/^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/iu.test(t))throw new Error("Text font package name is unsafe.");return z.join(e,"node_modules",...t.split("/"))}a(en,"packageRoot");async function _s(e,t){if("builtin"in t){let o=sr(t.builtin);return {sourceHash:o.sourceChecksum,browserHash:o.browserChecksum,description:`builtin:${o.id}@${o.version}`,license:o.license}}if("path"in t){let o=await l(e,z.join(e,t.path),d$1.texture,"Text source font");return {sourceHash:f(o.data),browserHash:f(o.data),description:t.path}}let r=z.join(en(e,t.package),t.file),n=await Qr(r,t.checksum,"Package text source font");return {sourceHash:f(n),browserHash:f(n),description:`${t.package}/${t.file}`}}a(_s,"resolveFontIdentity");async function As(e,t,r,n){if("builtin"in t){let i=Zr(t.builtin,r),[c,u]=await Yr(i,r,n===void 0?void 0:{root:e,filePath:n});return {source:c,sourceHash:i.sourceChecksum,browser:u,browserHash:i.browserChecksum,description:`builtin:${i.id}@${i.version}`,license:i.license}}if("path"in t){let i=await l(e,z.join(e,t.path),d$1.texture,"Text source font"),c=f(i.data);return {source:i.data,sourceHash:c,browser:i.data,browserHash:c,description:t.path}}let o=z.join(en(e,t.package),t.file),s=await Qr(o,t.checksum,"Package text source font"),a=f(s);return {source:s,sourceHash:a,browser:s,browserHash:a,description:`${t.package}/${t.file}`}}a(As,"resolveFont");function st(e,t){let r=t.replace(/^\/+/,""),n=z.resolve(e,"public",r),o=z.resolve(e,"public"),s=z.relative(o,n);if(s===""||s===".."||s.startsWith(`..${z.sep}`)||z.isAbsolute(s))throw new Error(`Deployed text path ${JSON.stringify(t)} escapes public/.`);return n}a(st,"deployedFile");function nr(e,t){return z.relative(e,t).split(z.sep).join("/")}a(nr,"portablePath");function tn(e){return e.endsWith(".json")?`${e.slice(0,-5)}.meta.json`:`${e}.meta.json`}a(tn,"metadataPath");function rn(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}a(rn,"bufferArray");function Cs(e,t){return t.filter(r=>r===65533||e.charToGlyphIndex(String.fromCodePoint(r))!==0)}a(Cs,"supportedCodePoints");function Ms(e,t,r,n){return new Promise((o,s)=>{ys(e,{filename:r,charset:t.map(a=>String.fromCodePoint(a)),outputType:"json",fieldType:"msdf",fontSize:n.size,distanceRange:n.distanceRange,texturePadding:n.padding,textureSize:[n.maxTextureSize,n.maxTextureSize],smartSize:true,pot:true},(a,i,c)=>{if(a)return s(a);if(i.length!==1||i[0]===void 0)return s(new Error(`Text glyphs require ${i.length} atlas pages; raise maxTextureSize or lower size.`));try{o({png:i[0].texture,data:xs(JSON.parse(c.data))});}catch(u){s(u);}});})}a(Ms,"generateBMFontData");function Fs(e,t,r){let n=1/e.info.size,o=e.common.base,s=t.unitsPerEm,a=t.tables.hhea;return {name:t.names?.fontFamily?.en??e.info.face,atlas:{type:"msdf",distanceRange:r.distanceRange,size:e.info.size,width:e.common.scaleW,height:e.common.scaleH,yOrigin:"top"},metrics:{emSize:1,lineHeight:(a.ascender-a.descender+a.lineGap)/s,ascender:a.ascender/s,descender:a.descender/s,underlineY:(t.tables.post?.underlinePosition??-s*.1)/s,underlineThickness:(t.tables.post?.underlineThickness??s*.05)/s},glyphs:e.chars.slice().sort((i,c)=>i.id-c.id).map(i=>({unicode:i.id,advance:i.xadvance*n,...i.width>0&&i.height>0?{planeBounds:{left:i.xoffset*n,bottom:(o-i.yoffset-i.height)*n,right:(i.xoffset+i.width)*n,top:(o-i.yoffset)*n},atlasBounds:{left:i.x,top:i.y,right:i.x+i.width,bottom:i.y+i.height}}:{}})),kerning:e.kernings.filter(i=>i.amount!==0).sort((i,c)=>i.first-c.first||i.second-c.second).map(i=>({unicode1:i.first,unicode2:i.second,advance:i.amount*n}))}}a(Fs,"convertMetrics");function nn(){return at}a(nn,"zstdFunctions");function Os(e){let t=PNG.sync.read(e),r=new Uint8Array(t.data.buffer,t.data.byteOffset,t.data.byteLength),o=nn().zstdCompressSync,s=o===void 0?"none":"zstd",a$1=at.constants.ZSTD_c_compressionLevel,i=o?.(r,a$1===void 0?{}:{params:{[a$1]:19}}),c=createDefaultContainer();c.vkFormat=VK_FORMAT_R8G8B8A8_UNORM,c.typeSize=1,c.pixelWidth=t.width,c.pixelHeight=t.height,c.supercompressionScheme=s==="zstd"?KHR_SUPERCOMPRESSION_ZSTD:KHR_SUPERCOMPRESSION_NONE,c.levels=[{levelData:i===void 0?r:new Uint8Array(i.buffer,i.byteOffset,i.byteLength),uncompressedByteLength:r.byteLength}];let u=a((l,m)=>({bitOffset:l*8,bitLength:7,channelType:m,samplePosition:[0,0,0,0],sampleLower:0,sampleUpper:255}),"sample");c.dataFormatDescriptor=[{vendorId:KHR_DF_VENDORID_KHRONOS,descriptorType:KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT,versionNumber:KHR_DF_VERSION,colorModel:KHR_DF_MODEL_RGBSDA,colorPrimaries:KHR_DF_PRIMARIES_BT709,transferFunction:KHR_DF_TRANSFER_LINEAR,flags:KHR_DF_FLAG_ALPHA_STRAIGHT,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[u(0,KHR_DF_CHANNEL_RGBSDA_RED),u(1,KHR_DF_CHANNEL_RGBSDA_GREEN),u(2,KHR_DF_CHANNEL_RGBSDA_BLUE),u(3,KHR_DF_CHANNEL_RGBSDA_ALPHA|KHR_DF_SAMPLE_DATATYPE_LINEAR)]}],c.keyValue.KTXwriter=`three-blocks text ${it}`,c.keyValue.KTXorientation="rd";let p=write(c,{keepWriter:true});return on(p,t.width,t.height),{bytes:p,width:t.width,height:t.height,compression:s}}a(Os,"createKtx2");function on(e,t,r){let n=read(e);if(n.vkFormat!==VK_FORMAT_R8G8B8A8_UNORM)throw new Error("Text atlas must use RGBA8 KTX2.");if(n.pixelWidth<=0||n.pixelHeight<=0||n.levels.length!==1||n.levels[0]===void 0)throw new Error("Text atlas KTX2 dimensions or levels are invalid.");if(t!==void 0&&n.pixelWidth!==t)throw new Error("Text atlas KTX2 width does not match metrics.");if(r!==void 0&&n.pixelHeight!==r)throw new Error("Text atlas KTX2 height does not match metrics.");if(n.keyValue.KTXorientation!=="rd")throw new Error("Text atlas KTX2 orientation must be rd.");let o=n.levels[0],s,a;if(n.supercompressionScheme===KHR_SUPERCOMPRESSION_ZSTD){let c=nn().zstdDecompressSync;if(c===void 0)throw new Error("This Node.js runtime cannot validate Zstandard KTX2 text atlases.");s=c(o.levelData),a="zstd";}else if(n.supercompressionScheme===KHR_SUPERCOMPRESSION_NONE)s=o.levelData,a="none";else throw new Error("Text atlas uses an unsupported KTX2 supercompression scheme.");let i=n.pixelWidth*n.pixelHeight*4;if(s.byteLength!==i||o.uncompressedByteLength!==i)throw new Error("Text atlas KTX2 decoded byte length is invalid.");return {width:n.pixelWidth,height:n.pixelHeight,compression:a}}a(on,"validateKtx2Bytes");function Ur(e){return `${JSON.stringify(e)}
1
+ import {c,d,b as b$1}from'./chunk-E6JYGHBW.js';export{a as DOCUMENTED_BROWSER_NOISE,l as createAttachedPlaywrightShaderDriver,j as createPlaywrightShaderDriver,k as createStaticPlaywrightShaderDriver,b as isDocumentedBrowserNoise,i as isRetryableShaderObservationNavigation,c as webgpuBrowserArgs,d as webgpuBrowserHeadless}from'./chunk-E6JYGHBW.js';import {a as a$1,l,d as d$1,f,j,e,i,g,m,h,x,r,s,o,k,c as c$1,G as G$1,v,w,D,u,t,C,N,M as M$1,J,p,L,K,b}from'./chunk-RQEPJ6GC.js';export{o as SHADER_ARTIFACT_DIRECTORY,P as SHADER_CAPTURE_CLIENT_ID,z as SHADER_COMMITTED_TIMING_FILE,w as SHADER_DEVTOOLS_VERSION,y as SHADER_LOCAL_TIMING_FILE,p as SHADER_PARITY_DIRECTORY,A as SHADER_PARITY_EVIDENCE_FILE,x as SHADER_PROVIDER_TRANSFORM_VERSION,n as SHADER_TOOL_CONFIG_FILE,S as applyShaderProviderTransform,U as assertShaderProviderTransform,T as createShaderProviderTransform,u as ensureShaderToolConfig,r as findShaderProjectRoot,t as inferShaderCaptureTarget,O as loadShaderCaptureRuntimeSource,s as loadShaderToolConfig,b as parseProjectMetadata,c as parseShaderReceipt,q as parseShaderToolConfig,I as readShaderCommittedTiming,F as readShaderLocalTiming,H as readShaderParityEvidence,G as readShaderTiming,E as serializeShaderManifest,B as shaderCoverage,D as stableStringify,C as validateShaderCapture,N as writeShaderArtifacts,J as writeShaderLocalTiming,K as writeShaderParityEvidence,M as writeShaderTimingTwins}from'./chunk-RQEPJ6GC.js';export{b as compareShaderScreenshots,a as shaderScreenshotMetrics}from'./chunk-UDUICSME.js';import {a}from'./chunk-EI7MMDWY.js';import {rm,mkdir,writeFile,rename,realpath,readdir,readFile,lstat}from'fs/promises';import z from'path';import {createRequire}from'module';import {createHash,randomUUID}from'crypto';import Mt,{platform,homedir}from'os';import {fileURLToPath}from'url';import*as at from'zlib';import at__default from'zlib';import {createDefaultContainer,VK_FORMAT_R8G8B8A8_UNORM,KHR_SUPERCOMPRESSION_ZSTD,KHR_SUPERCOMPRESSION_NONE,KHR_DF_FLAG_ALPHA_STRAIGHT,KHR_DF_TRANSFER_LINEAR,KHR_DF_PRIMARIES_BT709,KHR_DF_MODEL_RGBSDA,KHR_DF_VERSION,KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT,KHR_DF_VENDORID_KHRONOS,KHR_DF_CHANNEL_RGBSDA_RED,KHR_DF_CHANNEL_RGBSDA_GREEN,KHR_DF_CHANNEL_RGBSDA_BLUE,KHR_DF_CHANNEL_RGBSDA_ALPHA,KHR_DF_SAMPLE_DATATYPE_LINEAR,write,read,VK_FORMAT_R16G16B16A16_SFLOAT}from'ktx-parse';import ys from'msdf-bmfont-xml';import qr from'opentype.js';import {PNG}from'pngjs';import {SHADER_ADDRESS_SCHEMA_VERSION,SHADER_RECIPE_SCHEMA_VERSION,SHADER_HYDRATION_SCHEMA_VERSION}from'three-blocks/shaders';import {watch}from'fs';var Ar=4096,Eo=createRequire(import.meta.url),Cr,W=new Proxy({},{get(e,t){return Cr??=Eo("typescript"),Reflect.get(Cr,t)}});function ve(e){let t=e;for(;W.isParenthesizedExpression(t)||W.isAsExpression(t)||W.isSatisfiesExpression(t)||W.isNonNullExpression(t);)t=t.expression;return t}a(ve,"unwrap");function To(e){if(W.isIdentifier(e)||W.isStringLiteral(e)||W.isNumericLiteral(e))return e.text}a(To,"propertyName");function kt(e,t){let r=new Map;for(let n of e.properties){if(!W.isPropertyAssignment(n))throw new Error(`${t} may contain only static property assignments.`);let o=To(n.name);if(o===void 0||r.has(o))throw new Error(`${t} contains a computed or duplicate property.`);r.set(o,n.initializer);}return r}a(kt,"properties");function xt(e,t){if(e===void 0)throw new Error(`${t} is missing.`);let r=ve(e);if(!W.isObjectLiteralExpression(r))throw new Error(`${t} must be a static object literal.`);return r}a(xt,"objectLiteral");function Rt(e,t){if(e===void 0)throw new Error(`${t} is missing.`);let r=ve(e);if(!W.isStringLiteral(r)&&!W.isNoSubstitutionTemplateLiteral(r))throw new Error(`${t} must be a string literal.`);return r.text}a(Rt,"stringLiteral");function vt(e,t){if(e===void 0)throw new Error(`${t} is missing.`);let r=ve(e);if(!W.isNumericLiteral(r))throw new Error(`${t} must be a numeric literal.`);return Number(r.text)}a(vt,"numericLiteral");function Mr(e,t){if(e===void 0)throw new Error(`${t} is missing.`);let r=ve(e);if(!W.isArrayLiteralExpression(r))throw new Error(`${t} must be a static array literal.`);return r.elements}a(Mr,"arrayLiteral");function Bo(e,t){if(e===void 0)throw new Error(`${t} is missing.`);let r=ve(e);if(r.kind===W.SyntaxKind.NullKeyword)return null;if(!W.isNumericLiteral(r))throw new Error(`${t} must be null or a numeric literal.`);return Number(r.text)}a(Bo,"numericOrNullLiteral");function Po(e){return e.parseDiagnostics??[]}a(Po,"parseDiagnostics");function Et(e,t,r,n){let o=W.createSourceFile(t,e,W.ScriptTarget.Latest,true,W.ScriptKind.TS),s=Po(o);if(s.length>0)throw new Error(`Shader manifest is not valid TypeScript: ${W.flattenDiagnosticMessageText(s[0]?.messageText??"parse error"," ")}`);let a$1=o.statements.filter(W.isExportAssignment).filter(f=>!f.isExportEquals);if(a$1.length!==1)throw new Error("Shader manifest must contain exactly one default export.");let i=kt(xt(a$1[0]?.expression,"Shader manifest default export"),"Shader manifest"),c=i.get("version");if(c===void 0||!W.isNumericLiteral(ve(c))||Number(ve(c).getText(o))!==3)throw new Error("Shader manifest version must be the numeric literal 3.");if(Rt(i.get("scene"),"Shader manifest scene")!==r)throw new Error(`Shader manifest scene does not match "${r}".`);if(n){if(Rt(i.get("three"),"Shader manifest Three.js version")!==n.three||Rt(i.get("threeBlocks"),"Shader manifest Three Blocks version")!==n.threeBlocks)throw new Error("Shader manifest runtime versions do not match its receipt.");let f=kt(xt(i.get("runtime"),"Shader manifest runtime"),"Shader manifest runtime");if(Rt(f.get("id"),"Shader manifest runtime id")!==n.compatibility||vt(f.get("address"),"Shader manifest address schema")!==n.address||vt(f.get("recipe"),"Shader manifest recipe schema")!==n.recipe||vt(f.get("hydration"),"Shader manifest hydration schema")!==n.hydration)throw new Error("Shader manifest runtime compatibility schemas do not match its receipt.")}let u=kt(xt(i.get("entries"),"Shader manifest entries"),"Shader manifest entries");if(u.size===0||u.size>Ar)throw new Error(`Shader manifest must contain between 1 and ${Ar} entries.`);let p=Mr(i.get("modules"),"Shader manifest modules").map((f,h)=>{let y=ve(f);if(!W.isStringLiteral(y)&&!W.isNoSubstitutionTemplateLiteral(y))throw new Error(`Shader manifest module ${h} must be a WGSL string literal.`);if(y.text.length===0)throw new Error(`Shader manifest module ${h} is empty.`);return y.text}),l=Mr(i.get("states"),"Shader manifest states").map((f,h)=>{let y=kt(xt(f,`Shader manifest state ${h}`),`Shader manifest state ${h}`),b=a((A,C)=>{let K=Bo(y.get(A),`Shader manifest state ${h} ${A}`);if(K===null)return false;let S=p[K];if(S===void 0||!S.includes(C))throw new Error(`Shader manifest state ${h} ${A} does not reference a ${C} module.`);return true},"moduleAt"),x=b("vertex","@vertex"),R=b("fragment","@fragment"),w=b("compute","@compute");if(w&&(x||R))throw new Error(`Shader manifest state ${h} mixes render and compute stages.`);if(!w&&!x&&!R)throw new Error(`Shader manifest state ${h} contains no shader stage.`);return {vertex:x,fragment:R,compute:w}}),m={render:0,vertex:0,fragment:0,compute:0};for(let[f,h]of u){if(f.length===0||/[\u0000-\u001f\u007f]/.test(f))throw new Error("Shader manifest contains an invalid entry key.");let y=vt(h,`Shader manifest entry "${f}"`),b=l[y];if(b===void 0)throw new Error(`Shader manifest entry "${f}" references an absent state.`);(b.vertex||b.fragment)&&(m.render+=1),b.vertex&&(m.vertex+=1),b.fragment&&(m.fragment+=1),b.compute&&(m.compute+=1);}return m}a(Et,"inspectPrecompiledManifest");var Ao=createRequire(import.meta.url),Fr,G=new Proxy({},{get(e,t){return Fr??=Ao("typescript"),Reflect.get(Fr,t)}}),Co=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Mo=new Set(["script","style","template"]),Or=2e5,Fo={amp:"&",apos:"'",copy:"\xA9",deg:"\xB0",gt:">",hellip:"\u2026",ldquo:"\u201C",lsquo:"\u2018",lt:"<",mdash:"\u2014",nbsp:"\xA0",ndash:"\u2013",quot:'"',rdquo:"\u201D",rsquo:"\u2019"};function Oo(e){return e.replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z][a-z0-9]+);/giu,(t,r)=>{if(r.startsWith("#x")||r.startsWith("#X")){let n=Number.parseInt(r.slice(2),16);return nt(n)?String.fromCodePoint(n):t}if(r.startsWith("#")){let n=Number.parseInt(r.slice(1),10);return nt(n)?String.fromCodePoint(n):t}return Fo[r.toLowerCase()]??t})}a(Oo,"decodeHtmlEntities");function nt(e){return Number.isSafeInteger(e)&&e>=0&&e<=1114111&&!(e>=55296&&e<=57343)}a(nt,"validCodePoint");function Lr(e){return nt(e)&&e>=32&&!(e>=127&&e<=159)}a(Lr,"renderableCodePoint");function Io(e){return /(?:^|\s)data-canvas-text(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?(?=\s|\/?>)/iu.test(e)}a(Io,"hasCanvasTextAttribute");function Kt(e){let t=[],r=[],n=e.match(/<!--[\s\S]*?-->|<![^>]*>|<[^>]*>|[^<]+/gu)??[];for(let o of n){if(!o.startsWith("<")){if(r.some(c=>c.synchronized)&&!r.some(c=>c.skipped)){let c=Oo(o);c.trim().length>0&&t.push(c);}continue}if(o.startsWith("<!--")||o.startsWith("<!")||o.startsWith("<?"))continue;let s=/^<\s*\//u.test(o),a=/^<\s*\/?\s*([a-z][a-z0-9:-]*)/iu.exec(o)?.[1]?.toLowerCase();if(!a)continue;if(s){let c=r.map(u=>u.tag).lastIndexOf(a);c>=0&&r.splice(c);continue}/\/\s*>$/u.test(o)||Co.has(a)||r.push({tag:a,synchronized:Io(o),skipped:Mo.has(a)});}return t}a(Kt,"extractCanvasTextFromHtml");function Lo(e){let t=new Set,r=new Set;for(let n of e.statements){if(!G.isImportDeclaration(n)||!G.isStringLiteral(n.moduleSpecifier)||n.moduleSpecifier.text!=="three-blocks/text")continue;let o=n.importClause?.namedBindings;if(o&&G.isNamespaceImport(o)&&r.add(o.name.text),o&&G.isNamedImports(o))for(let s of o.elements)(s.propertyName?.text??s.name.text)==="defineTextContent"&&t.add(s.name.text);}return {named:t,namespaces:r}}a(Lo,"importedTextHelpers");function jo(e,t){return G.isIdentifier(e)?t.named.has(e.text):G.isPropertyAccessExpression(e)&&G.isIdentifier(e.expression)&&t.namespaces.has(e.expression.text)&&e.name.text==="defineTextContent"}a(jo,"isDefineTextContentCall");function No(e){let t=e;for(;G.isParenthesizedExpression(t)||G.isAsExpression(t)||G.isSatisfiesExpression(t)||G.isTypeAssertionExpression(t);)t=t.expression;return t}a(No,"unwrapExpression");function zt(e,t,r){let n=No(e);if(G.isStringLiteral(n)||G.isNoSubstitutionTemplateLiteral(n)){t.push(n.text);return}if(G.isArrayLiteralExpression(n)){for(let a of n.elements){if(G.isSpreadElement(a))throw new Error(`${r}: defineTextContent() cannot use spread elements.`);zt(a,t,r);}return}if(G.isObjectLiteralExpression(n)){for(let a of n.properties){if(!G.isPropertyAssignment(a))throw new Error(`${r}: defineTextContent() accepts only static property assignments.`);zt(a.initializer,t,r);}return}let o=n.getStart(),s=n.getSourceFile().getLineAndCharacterOfPosition(o).line+1;throw new Error(`${r}:${s}: defineTextContent() contains dynamic text; declare a Unicode range or an explicit static string.`)}a(zt,"collectStaticStrings");function qt(e,t="content.ts"){let r=G.createSourceFile(t,e,G.ScriptTarget.Latest,true,t.endsWith(".tsx")?G.ScriptKind.TSX:G.ScriptKind.TS),n=Lo(r),o=[];function s(a){if(G.isCallExpression(a)&&jo(a.expression,n)){if(a.arguments.length!==1||!a.arguments[0])throw new Error(`${t}: defineTextContent() requires exactly one static argument.`);zt(a.arguments[0],o,t);return}G.forEachChild(a,s);}return a(s,"visit"),s(r),o}a(qt,"extractDefinedTextContent");function Do(e){let t=[];if(e==="latin"){for(let r=32;r<=126;r++)t.push(r);for(let r of "\u2018\u2019\u201C\u201D\u2013\u2014\u2026\u2022\xB7\xAB\xBB\u2039\u203A\u20AC\xA3\xA5\xB0\xB1\xD7\xF7\xA9\xAE\u2122\xA0"){let n=r.codePointAt(0);n!==void 0&&t.push(n);}}else {for(let r=12353;r<=12438;r++)t.push(r);for(let r=12443;r<=12447;r++)t.push(r);for(let r=12448;r<=12543;r++)t.push(r);for(let r of "\u3000\u3001\u3002\u300C\u300D\u300E\u300F\uFF08\uFF09\u30FB\u30FC\u301C\u3008\u3009\u300A\u300B\u3010\u3011\uFF01\uFF1F\uFF1A\uFF1B\uFF10\uFF11\uFF12\uFF13\uFF14\uFF15\uFF16\uFF17\uFF18\uFF19\uFF05\uFF06"){let n=r.codePointAt(0);n!==void 0&&t.push(n);}}return t}a(Do,"presetCodePoints");function Ir(e,t){for(let r of t.normalize("NFC")){let n=r.codePointAt(0);n!==void 0&&Lr(n)&&e.add(n);}}a(Ir,"addCharacters");function Xt(e,t={}){let r=new Set;for(let i of e)Ir(r,i);t.additionalCharacters&&Ir(r,t.additionalCharacters);for(let i of t.presets??[])for(let c of Do(i))r.add(c);let n=0;for(let i of t.ranges??[]){if(!nt(i.start)||!nt(i.end)||i.end<i.start)throw new RangeError("Text Unicode ranges must contain ordered Unicode scalar values.");if(n+=i.end-i.start+1,n>Or)throw new RangeError(`Configured Unicode ranges exceed the ${Or}-code-point safety limit.`);for(let c=i.start;c<=i.end;c++)Lr(c)&&r.add(c);}r.add(32),r.add(63),r.add(65533);let o=[...r].sort((i,c)=>i-c),s=o.map(i=>String.fromCodePoint(i)).join(""),a=createHash("sha256").update(s.normalize("NFC")).digest("hex");return {codePoints:o,characters:s,hash:a}}a(Xt,"buildGlyphSet");var Vo=createRequire(import.meta.url),jr,M=new Proxy({},{get(e,t){return jr??=Vo("typescript"),Reflect.get(jr,t)}});function Uo(e){let t=e;for(;M.isParenthesizedExpression(t)||M.isAsExpression(t)||M.isSatisfiesExpression(t)||M.isTypeAssertionExpression(t);)t=t.expression;return t}a(Uo,"unwrap");function Wo(e,t){if(M.isIdentifier(e)||M.isStringLiteral(e)||M.isNumericLiteral(e))return e.text;throw new Error(`${t}: text configuration property names must be static.`)}a(Wo,"propertyName");function Tt(e,t){let r=Uo(e);if(M.isStringLiteral(r)||M.isNoSubstitutionTemplateLiteral(r))return r.text;if(M.isNumericLiteral(r))return Number(r.text);if(r.kind===M.SyntaxKind.TrueKeyword)return true;if(r.kind===M.SyntaxKind.FalseKeyword)return false;if(r.kind===M.SyntaxKind.NullKeyword)return null;if(M.isPrefixUnaryExpression(r)&&(r.operator===M.SyntaxKind.MinusToken||r.operator===M.SyntaxKind.PlusToken)){let o=Tt(r.operand,t);if(typeof o=="number")return r.operator===M.SyntaxKind.MinusToken?-o:o}if(M.isArrayLiteralExpression(r))return r.elements.map(o=>{if(M.isSpreadElement(o))throw new Error(`${t}: text configuration cannot use spread elements.`);return Tt(o,t)});if(M.isObjectLiteralExpression(r)){let o=Object.create(null);for(let s of r.properties){if(!M.isPropertyAssignment(s))throw new Error(`${t}: text configuration accepts only static property assignments.`);let a=Wo(s.name,t);if(Object.hasOwn(o,a))throw new Error(`${t}: duplicate text configuration property "${a}".`);o[a]=Tt(s.initializer,t);}return o}let n=r.getSourceFile().getLineAndCharacterOfPosition(r.getStart()).line+1;throw new Error(`${t}:${n}: text configuration must be statically inspectable.`)}a(Tt,"evaluateStatic");function Go(e){let t=new Set,r=new Set;for(let n of e.statements){if(!M.isImportDeclaration(n)||!M.isStringLiteral(n.moduleSpecifier)||n.moduleSpecifier.text!=="three-blocks/text")continue;let o=n.importClause?.namedBindings;if(o&&M.isNamespaceImport(o)&&r.add(o.name.text),o&&M.isNamedImports(o))for(let s of o.elements)(s.propertyName?.text??s.name.text)==="defineText"&&t.add(s.name.text);}return {named:t,namespaces:r}}a(Go,"helperNames");function zo(e,t){return M.isIdentifier(e)?t.named.has(e.text):M.isPropertyAccessExpression(e)&&M.isIdentifier(e.expression)&&t.namespaces.has(e.expression.text)&&e.name.text==="defineText"}a(zo,"isDefineTextCall");function ge(e,t){if(typeof e!="string"||e.trim().length===0)throw new Error(`${t} must be a non-empty string.`);return e}a(ge,"requiredString");function Bt(e,t,r=false){if(!Array.isArray(e)||!r&&e.length===0)throw new Error(`${t} must be ${r?"an":"a non-empty"} array of strings.`);return e.map((n,o)=>ge(n,`${t}[${o}]`))}a(Bt,"stringArray");function Pt(e,t){if(e.includes("\\")||z.posix.isAbsolute(e)||z.posix.normalize(e)!==e||e===".."||e.startsWith("../")||/[\u0000-\u001f\u007f]/u.test(e))throw new Error(`${t} must be a safe project-relative path.`);return e}a(Pt,"safeProjectPath");function Ko(e,t){if(!a$1(e))throw new Error(`${t} must be an object.`);let r=Object.keys(e).sort();if(r.length===1&&r[0]==="builtin")return {builtin:ge(e.builtin,`${t}.builtin`)};if(r.length===1&&r[0]==="path")return {path:Pt(ge(e.path,`${t}.path`),`${t}.path`)};if(r.join(",")==="checksum,file,package")return {package:ge(e.package,`${t}.package`),file:Pt(ge(e.file,`${t}.file`),`${t}.file`),checksum:ge(e.checksum,`${t}.checksum`)};throw new Error(`${t} must select exactly one supported source.`)}a(Ko,"parseFontSource");function Jt(e,t){let r=ge(e,t);if(r.includes("\\")||/[\u0000-\u001f\u007f]/u.test(r)||r.split("/").includes(".."))throw new Error(`${t} is unsafe.`);return r}a(Jt,"deployedPath");function qo(e){if(e===void 0)return {};if(!a$1(e))throw new Error("Text generation options must be an object.");let t=e.presets===void 0?void 0:Bt(e.presets,"Text generation presets",true).map(c=>{if(c!=="latin"&&c!=="japanese-kana")throw new Error(`Unsupported text preset "${c}".`);return c}),r;if(e.ranges!==void 0){if(!Array.isArray(e.ranges))throw new Error("Text generation ranges must be an array.");r=e.ranges.map((c,u)=>{if(!a$1(c)||typeof c.start!="number"||typeof c.end!="number")throw new Error(`Text generation range ${u} is invalid.`);return {start:c.start,end:c.end}});}let n=a(c=>{let u=e[c];if(u!==void 0){if(typeof u!="number"||!Number.isFinite(u))throw new Error(`Text generation ${c} must be finite.`);return u}},"numeric"),o=n("size"),s=n("distanceRange"),a$2=n("padding"),i=n("maxTextureSize");return {...t===void 0?{}:{presets:t},...r===void 0?{}:{ranges:r},...e.additionalCharacters===void 0?{}:{additionalCharacters:ge(e.additionalCharacters,"Text generation additionalCharacters")},...o===void 0?{}:{size:o},...s===void 0?{}:{distanceRange:s},...a$2===void 0?{}:{padding:a$2},...i===void 0?{}:{maxTextureSize:i}}}a(qo,"parseGeneration");function Xo(e){if(!a$1(e)||e.schemaVersion!==void 0&&e.schemaVersion!==1)throw new Error("Text configuration must use schemaVersion 1.");let t=Bt(e.content,"Text content inputs").map(o=>Pt(o,"Text content input"));if(!a$1(e.fonts)||Object.keys(e.fonts).length===0)throw new Error("Text fonts must be a non-empty object.");let r={},n=0;for(let[o,s]of Object.entries(e.fonts)){if(ge(o,"Text font key"),!a$1(s))throw new Error(`Text font "${o}" must be an object.`);let a=s.default===true;a&&n++,r[o]={source:Ko(s.source,`Text font "${o}" source`),browser:Jt(s.browser,`Text font "${o}" browser path`),atlas:Jt(s.atlas,`Text font "${o}" atlas path`),metrics:Jt(s.metrics,`Text font "${o}" metrics path`),families:Bt(s.families,`Text font "${o}" families`),languages:s.languages===void 0?[]:Bt(s.languages,`Text font "${o}" languages`,true),default:a};}if(Object.keys(r).length>1&&n!==1)throw new Error("Multiple text fonts require exactly one default route.");if(n>1)throw new Error("Text fonts can select only one default route.");return {schemaVersion:1,content:t,fonts:r,generation:qo(e.generation)}}a(Xo,"validateConfiguration");function Nr(e,t="three-blocks.text.ts"){let r=M.createSourceFile(t,e,M.ScriptTarget.Latest,true,M.ScriptKind.TS),n=Go(r),o=[];function s(a){if(M.isCallExpression(a)&&zo(a.expression,n)){if(a.arguments.length!==1||!a.arguments[0])throw new Error(`${t}: defineText() requires one static argument.`);o.push(Tt(a.arguments[0],t));return}M.forEachChild(a,s);}if(a(s,"visit"),s(r),o.length!==1)throw new Error(`${t} must contain exactly one imported defineText() call.`);return Xo(o[0])}a(Nr,"parseTextConfiguration");function Zt(e,t){if(typeof e=="string")t.push(e);else if(Array.isArray(e))for(let r of e)Zt(r,t);else if(a$1(e))for(let r of Object.values(e))Zt(r,t);}a(Zt,"jsonStrings");async function $t(e,t="three-blocks.text.ts"){let r=Pt(t,"Text configuration path"),n=await l(e,z.join(e,r),d$1.semanticInput,"Text configuration");return Nr(n.data.toString("utf8"),r)}a($t,"readTextConfiguration");async function _t(e,t){let r=[],n={},o=0;for(let s of t.content){let a=await l(e,z.join(e,s),d$1.semanticInput,"Text content input");if(o+=a.data.byteLength,o>d$1.semanticTotal)throw new Error("Text content inputs exceed the total inspection size limit.");n[s]=f(a.data);let i=a.data.toString("utf8"),c=z.extname(s).toLowerCase();if(c===".html"||c===".htm")r.push(...Kt(i));else if([".ts",".tsx",".js",".jsx",".mts",".cts",".mjs",".cjs"].includes(c))r.push(...qt(i,s));else if(c===".json")Zt(JSON.parse(i),r);else if(c===".txt"||c===".md")r.push(i);else throw new Error(`Unsupported configured text content type: ${s}.`)}return {values:r,glyphs:Xt(r,t.generation),inputs:n}}a(_t,"discoverTextContent");var or=1,it="1.0.0",ws=Object.freeze({"geist-sans":{id:"geist-sans",family:"Geist Sans",version:"1.600",license:"OFL-1.1",licenseFile:"OFL-1.1.txt",sourceFile:"geist-sans/Geist-Variable.ttf",sourceUrl:"https://raw.githubusercontent.com/vercel/geist-font/1.6.0/fonts/Geist/variable/Geist%5Bwght%5D.ttf",sourceBytes:168472,sourceChecksum:"995c579489b33cd28a6732d7aa7ca1b46c2faa832c18b4063933d7652c39932b",browserFile:"geist-sans/Geist-Variable.woff2",browserUrl:"https://raw.githubusercontent.com/vercel/geist-font/449415077ee4ffc191b4e7e557cd35e88b1b98fd/packages/next/dist/fonts/geist-sans/Geist-Variable.woff2",browserBytes:58512,browserChecksum:"46525b05bbf4527d263f8624ca7024c7d0dce3c64430267d30c31c6dd3821e4d"},"noto-sans-jp":{id:"noto-sans-jp",family:"Noto Sans JP",version:"2.004-H2",license:"OFL-1.1",licenseFile:"OFL-1.1.txt",sourceFile:"noto-sans-jp/NotoSansJP[wght].ttf",sourceUrl:"https://raw.githubusercontent.com/google/fonts/295d98a7a0c17c68f1341eaeea354e7960ea70d3/ofl/notosansjp/NotoSansJP%5Bwght%5D.ttf",sourceBytes:9589900,sourceChecksum:"c2f3b4d463500a2ddcd3849cded1fceeb9fd6d1c32e6cbecd568453ba50fc68f",browserFile:"noto-sans-jp/NotoSansJP[wght].woff2",browserUrl:"https://raw.githubusercontent.com/RenaudRohlinger/three-blocks-monorepo/364a50cc5f6f92735a110b50144e8d62404c9d87/packages/three-blocks-devtools/fonts/noto-sans-jp/NotoSansJP%5Bwght%5D.woff2",browserBytes:4350080,browserChecksum:"6fd94964d1990baa2a392cea7a036683d2b80b9dfd590cb3918e8dab98d8e188"}}),bs="THREE_BLOCKS_FONT_CACHE_DIR",Ss=6e4,At=new Map,ks=fileURLToPath(new URL("../fonts/",import.meta.url));function ae(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} must be finite.`);return e}a(ae,"finiteNumber");function Ee(e,t){let r=ae(e,t);if(!Number.isSafeInteger(r))throw new Error(`${t} must be an integer.`);return r}a(Ee,"integer");function xs(e){if(!a$1(e)||!a$1(e.info)||!a$1(e.common)||!Array.isArray(e.chars))throw new Error("MSDF generator returned invalid BMFont metadata.");let t=e.chars.map((o,s)=>{if(!a$1(o))throw new Error(`BMFont character ${s} is invalid.`);return {id:Ee(o.id,`BMFont character ${s}.id`),x:ae(o.x,`BMFont character ${s}.x`),y:ae(o.y,`BMFont character ${s}.y`),width:ae(o.width,`BMFont character ${s}.width`),height:ae(o.height,`BMFont character ${s}.height`),xoffset:ae(o.xoffset,`BMFont character ${s}.xoffset`),yoffset:ae(o.yoffset,`BMFont character ${s}.yoffset`),xadvance:ae(o.xadvance,`BMFont character ${s}.xadvance`)}}),r=e.kernings===void 0?[]:e.kernings;if(!Array.isArray(r))throw new Error("BMFont kernings are invalid.");let n=r.map((o,s)=>{if(!a$1(o))throw new Error(`BMFont kerning ${s} is invalid.`);return {first:Ee(o.first,`BMFont kerning ${s}.first`),second:Ee(o.second,`BMFont kerning ${s}.second`),amount:ae(o.amount,`BMFont kerning ${s}.amount`)}});return {info:{size:ae(e.info.size,"BMFont info.size"),face:typeof e.info.face=="string"?e.info.face:"Font"},common:{base:ae(e.common.base,"BMFont common.base"),scaleW:Ee(e.common.scaleW,"BMFont common.scaleW"),scaleH:Ee(e.common.scaleH,"BMFont common.scaleH")},chars:t,kernings:n}}a(xs,"parseBMFont");function Xr(e){let t=e.generation.size??48,r=e.generation.distanceRange??8,n=e.generation.padding??2,o=e.generation.maxTextureSize??4096;if(!Number.isInteger(t)||t<8||t>256)throw new Error("Text generation size must be an integer from 8 to 256.");if(!Number.isInteger(r)||r<1||r>64)throw new Error("Text generation distanceRange must be an integer from 1 to 64.");if(!Number.isInteger(n)||n<0||n>32)throw new Error("Text generation padding must be an integer from 0 to 32.");if(!Number.isInteger(o)||o<64||o>8192||(o&o-1)!==0)throw new Error("Text generation maxTextureSize must be a power of two from 64 to 8192.");return {size:t,distanceRange:r,padding:n,maxTextureSize:o}}a(Xr,"atlasOptions");function sr(e){let t=ws[e];if(t===void 0)throw new Error(`Unknown built-in font ${JSON.stringify(e)}.`);return t}a(sr,"builtinFontMetadata");function Jr(e){let t=e.cacheDirectory??process.env[bs];return t?z.resolve(t):platform()==="darwin"?z.join(homedir(),"Library","Caches","three-blocks","fonts"):platform()==="win32"?z.join(process.env.LOCALAPPDATA?.trim()||z.join(homedir(),"AppData","Local"),"Three Blocks","Cache","fonts"):z.join(process.env.XDG_CACHE_HOME?.trim()||z.join(homedir(),".cache"),"three-blocks","fonts")}a(Jr,"fontCacheRoot");function Hr(e,t){return t==="source"?{font:e,kind:t,file:e.sourceFile,url:e.sourceUrl,bytes:e.sourceBytes,checksum:e.sourceChecksum,...e.sourceArchive===void 0?{}:{archive:e.sourceArchive}}:{font:e,kind:t,file:e.browserFile,url:e.browserUrl,bytes:e.browserBytes,checksum:e.browserChecksum}}a(Hr,"builtinAsset");function Zr(e,t){let r=sr(e),n=t.mapBuiltinFont?.(r)??r;if(n.id!==r.id||n.version!==r.version||n.sourceBytes!==r.sourceBytes||n.sourceChecksum!==r.sourceChecksum||n.browserBytes!==r.browserBytes||n.browserChecksum!==r.browserChecksum)throw new Error(`Runtime metadata for built-in font ${JSON.stringify(e)} changed its pinned identity.`);return n}a(Zr,"runtimeBuiltinFontMetadata");function Rs(e,t){return z.join(Jr(t),e.font.id,e.font.version,e.checksum,z.basename(e.file))}a(Rs,"builtinCachePath");async function vs(e$1,t){try{let r=await j(e$1,d$1.texture,`${t.font.id} cached ${t.kind} font`);if(r.data.byteLength===t.bytes&&f(r.data)===t.checksum)return r.data;await rm(e$1,{force:!0});return}catch(r){if(e(r)==="ENOENT")return;throw r}}a(vs,"readCachedFont");async function Es(e$1){try{let t=await j(z.join(ks,e$1.file),e$1.bytes,`${e$1.font.id} packaged ${e$1.kind} font`);return t.data.byteLength===e$1.bytes&&f(t.data)===e$1.checksum?t.data:void 0}catch(t){if(e(t)==="ENOENT")return;throw t}}a(Es,"readPackagedFont");async function Ts(e,t){try{let r=await l(e.root,e.filePath,t.bytes,`${t.font.id} existing browser font output`);return r.data.byteLength!==t.bytes||f(r.data)!==t.checksum?void 0:r.data}catch{return}}a(Ts,"readBuiltinBrowserSeed");function Bs(e,t,r){let n=Math.max(0,e.byteLength-65557),o=-1;for(let u=e.byteLength-22;u>=n;u--)if(e.readUInt32LE(u)===101010256){o=u;break}if(o<0)throw new Error("downloaded ZIP has no end-of-central-directory record");let s=e.readUInt16LE(o+10),a=e.readUInt32LE(o+12),i=e.readUInt32LE(o+16);if(i+a>o)throw new Error("downloaded ZIP central directory is out of bounds");let c=i;for(let u=0;u<s;u++){if(c+46>e.byteLength||e.readUInt32LE(c)!==33639248)throw new Error("downloaded ZIP central directory is invalid");let p=e.readUInt16LE(c+10),l=e.readUInt32LE(c+20),m=e.readUInt32LE(c+24),f=e.readUInt16LE(c+28),h=e.readUInt16LE(c+30),y=e.readUInt16LE(c+32),b=e.readUInt32LE(c+42),x=c+46+f+h+y;if(x>e.byteLength)throw new Error("downloaded ZIP entry metadata is out of bounds");let R=e.subarray(c+46,c+46+f).toString("utf8");if(c=x,R!==t)continue;if(m!==r)throw new Error(`ZIP entry has ${m} bytes; expected ${r}`);if(b+30>e.byteLength||e.readUInt32LE(b)!==67324752)throw new Error("downloaded ZIP local entry is invalid");let w=e.readUInt16LE(b+26),A=e.readUInt16LE(b+28),C=b+30+w+A;if(C+l>e.byteLength)throw new Error("downloaded ZIP entry data is out of bounds");let K=e.subarray(C,C+l);if(p===0)return Buffer.from(K);if(p===8)return at.inflateRawSync(K,{maxOutputLength:r});throw new Error(`ZIP entry uses unsupported compression method ${p}`)}throw new Error(`downloaded ZIP does not contain ${JSON.stringify(t)}`)}a(Bs,"zipEntry");async function Ps(e,t){let r=new URL(e.url);if(r.protocol!=="https:")throw new Error(`Built-in font source must use HTTPS: ${e.url}.`);let n;try{n=await t(r,{signal:AbortSignal.timeout(Ss)});}catch(h){throw new Error(`request failed: ${h instanceof Error?h.message:String(h)}`,{cause:h})}if(!n.ok)throw new Error(`server returned HTTP ${n.status} ${n.statusText}`.trim());let o=e.archive?.bytes??e.bytes,s=e.archive?.checksum??e.checksum,a=n.headers.get("content-length");if(a!==null){let h=Number(a);if(!Number.isSafeInteger(h)||h!==o)throw new Error(`server declared ${a} bytes; expected ${o}`)}if(n.body===null)throw new Error("server returned an empty response body");let i=n.body.getReader(),c=[],u=0;for(;;){let h=await i.read();if(h.done)break;if(u+=h.value.byteLength,u>o||u>d$1.texture)throw await i.cancel(),new Error(`download exceeded the expected ${o}-byte size`);c.push(Buffer.from(h.value.buffer,h.value.byteOffset,h.value.byteLength));}let p=Buffer.concat(c,u);if(p.byteLength!==o)throw new Error(`downloaded ${p.byteLength} bytes; expected ${o}`);let l=f(p);if(l!==s)throw new Error(`checksum mismatch: expected ${s}, received ${l}`);let m=e.archive===void 0?p:Bs(p,e.archive.entry,e.bytes);if(m.byteLength!==e.bytes)throw new Error(`resolved ${m.byteLength} bytes; expected ${e.bytes}`);let f$1=f(m);if(f$1!==e.checksum)throw new Error(`resolved checksum mismatch: expected ${e.checksum}, received ${f$1}`);return m}a(Ps,"downloadFont");async function Qt(e,t){await mkdir(z.dirname(e),{recursive:true});let r=`${e}.${process.pid}.${randomUUID()}.tmp`;try{await writeFile(r,t,{flag:"wx"}),await rename(r,e);}finally{await rm(r,{force:true});}}a(Qt,"writeCachedFont");async function Vr(e,t,r){let n=Rs(e,t),o=At.get(n);if(o)return o;let s=(async()=>{let a=await vs(n,e);if(a)return a;if(t.fetch===void 0&&t.mapBuiltinFont===void 0){let i=await Es(e);if(i!==void 0)return await Qt(n,i),i}if(r!==void 0){let i=await Ts(r,e);if(i!==void 0)return await Qt(n,i),i}try{let i=await Ps(e,t.fetch??globalThis.fetch);return await Qt(n,i),i}catch(i){throw new Error(`Could not download the built-in ${e.font.id} ${e.kind} font from ${e.url}: ${i instanceof Error?i.message:String(i)}. Connect once to prewarm the checksum-keyed cache at ${JSON.stringify(Jr(t))}, or configure source.path/source.package for fully offline text generation.`,{cause:i})}})();At.set(n,s);try{return await s}finally{At.get(n)===s&&At.delete(n);}}a(Vr,"cachedBuiltinAsset");async function Yr(e,t,r){let[n,o]=await Promise.allSettled([Vr(Hr(e,"source"),t),Vr(Hr(e,"browser"),t,r)]);if(n.status==="rejected")throw n.reason;if(o.status==="rejected")throw o.reason;return [n.value,o.value]}a(Yr,"cachedBuiltinPair");async function $s(e,t={}){let r=Zr(e,t);await Yr(r,t);}a($s,"prewarmBuiltinFont");async function Qr(e,t,r){let n=await j(e,d$1.texture,r),o=f(n.data);if(t!=="pending"&&o!==t)throw new Error(`${r} checksum mismatch: expected ${t}, received ${o}.`);return n.data}a(Qr,"checkedExternalFile");function en(e,t){if(!/^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/iu.test(t))throw new Error("Text font package name is unsafe.");return z.join(e,"node_modules",...t.split("/"))}a(en,"packageRoot");async function _s(e,t){if("builtin"in t){let o=sr(t.builtin);return {sourceHash:o.sourceChecksum,browserHash:o.browserChecksum,description:`builtin:${o.id}@${o.version}`,license:o.license}}if("path"in t){let o=await l(e,z.join(e,t.path),d$1.texture,"Text source font");return {sourceHash:f(o.data),browserHash:f(o.data),description:t.path}}let r=z.join(en(e,t.package),t.file),n=await Qr(r,t.checksum,"Package text source font");return {sourceHash:f(n),browserHash:f(n),description:`${t.package}/${t.file}`}}a(_s,"resolveFontIdentity");async function As(e,t,r,n){if("builtin"in t){let i=Zr(t.builtin,r),[c,u]=await Yr(i,r,n===void 0?void 0:{root:e,filePath:n});return {source:c,sourceHash:i.sourceChecksum,browser:u,browserHash:i.browserChecksum,description:`builtin:${i.id}@${i.version}`,license:i.license}}if("path"in t){let i=await l(e,z.join(e,t.path),d$1.texture,"Text source font"),c=f(i.data);return {source:i.data,sourceHash:c,browser:i.data,browserHash:c,description:t.path}}let o=z.join(en(e,t.package),t.file),s=await Qr(o,t.checksum,"Package text source font"),a=f(s);return {source:s,sourceHash:a,browser:s,browserHash:a,description:`${t.package}/${t.file}`}}a(As,"resolveFont");function st(e,t){let r=t.replace(/^\/+/,""),n=z.resolve(e,"public",r),o=z.resolve(e,"public"),s=z.relative(o,n);if(s===""||s===".."||s.startsWith(`..${z.sep}`)||z.isAbsolute(s))throw new Error(`Deployed text path ${JSON.stringify(t)} escapes public/.`);return n}a(st,"deployedFile");function nr(e,t){return z.relative(e,t).split(z.sep).join("/")}a(nr,"portablePath");function tn(e){return e.endsWith(".json")?`${e.slice(0,-5)}.meta.json`:`${e}.meta.json`}a(tn,"metadataPath");function rn(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}a(rn,"bufferArray");function Cs(e,t){return t.filter(r=>r===65533||e.charToGlyphIndex(String.fromCodePoint(r))!==0)}a(Cs,"supportedCodePoints");function Ms(e,t,r,n){return new Promise((o,s)=>{ys(e,{filename:r,charset:t.map(a=>String.fromCodePoint(a)),outputType:"json",fieldType:"msdf",fontSize:n.size,distanceRange:n.distanceRange,texturePadding:n.padding,textureSize:[n.maxTextureSize,n.maxTextureSize],smartSize:true,pot:true},(a,i,c)=>{if(a)return s(a);if(i.length!==1||i[0]===void 0)return s(new Error(`Text glyphs require ${i.length} atlas pages; raise maxTextureSize or lower size.`));try{o({png:i[0].texture,data:xs(JSON.parse(c.data))});}catch(u){s(u);}});})}a(Ms,"generateBMFontData");function Fs(e,t,r){let n=1/e.info.size,o=e.common.base,s=t.unitsPerEm,a=t.tables.hhea;return {name:t.names?.fontFamily?.en??e.info.face,atlas:{type:"msdf",distanceRange:r.distanceRange,size:e.info.size,width:e.common.scaleW,height:e.common.scaleH,yOrigin:"top"},metrics:{emSize:1,lineHeight:(a.ascender-a.descender+a.lineGap)/s,ascender:a.ascender/s,descender:a.descender/s,underlineY:(t.tables.post?.underlinePosition??-s*.1)/s,underlineThickness:(t.tables.post?.underlineThickness??s*.05)/s},glyphs:e.chars.slice().sort((i,c)=>i.id-c.id).map(i=>({unicode:i.id,advance:i.xadvance*n,...i.width>0&&i.height>0?{planeBounds:{left:i.xoffset*n,bottom:(o-i.yoffset-i.height)*n,right:(i.xoffset+i.width)*n,top:(o-i.yoffset)*n},atlasBounds:{left:i.x,top:i.y,right:i.x+i.width,bottom:i.y+i.height}}:{}})),kerning:e.kernings.filter(i=>i.amount!==0).sort((i,c)=>i.first-c.first||i.second-c.second).map(i=>({unicode1:i.first,unicode2:i.second,advance:i.amount*n}))}}a(Fs,"convertMetrics");function nn(){return at}a(nn,"zstdFunctions");function Os(e){let t=PNG.sync.read(e),r=new Uint8Array(t.data.buffer,t.data.byteOffset,t.data.byteLength),o=nn().zstdCompressSync,s=o===void 0?"none":"zstd",a$1=at.constants.ZSTD_c_compressionLevel,i=o?.(r,a$1===void 0?{}:{params:{[a$1]:19}}),c=createDefaultContainer();c.vkFormat=VK_FORMAT_R8G8B8A8_UNORM,c.typeSize=1,c.pixelWidth=t.width,c.pixelHeight=t.height,c.supercompressionScheme=s==="zstd"?KHR_SUPERCOMPRESSION_ZSTD:KHR_SUPERCOMPRESSION_NONE,c.levels=[{levelData:i===void 0?r:new Uint8Array(i.buffer,i.byteOffset,i.byteLength),uncompressedByteLength:r.byteLength}];let u=a((l,m)=>({bitOffset:l*8,bitLength:7,channelType:m,samplePosition:[0,0,0,0],sampleLower:0,sampleUpper:255}),"sample");c.dataFormatDescriptor=[{vendorId:KHR_DF_VENDORID_KHRONOS,descriptorType:KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT,versionNumber:KHR_DF_VERSION,colorModel:KHR_DF_MODEL_RGBSDA,colorPrimaries:KHR_DF_PRIMARIES_BT709,transferFunction:KHR_DF_TRANSFER_LINEAR,flags:KHR_DF_FLAG_ALPHA_STRAIGHT,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[u(0,KHR_DF_CHANNEL_RGBSDA_RED),u(1,KHR_DF_CHANNEL_RGBSDA_GREEN),u(2,KHR_DF_CHANNEL_RGBSDA_BLUE),u(3,KHR_DF_CHANNEL_RGBSDA_ALPHA|KHR_DF_SAMPLE_DATATYPE_LINEAR)]}],c.keyValue.KTXwriter=`three-blocks text ${it}`,c.keyValue.KTXorientation="rd";let p=write(c,{keepWriter:true});return on(p,t.width,t.height),{bytes:p,width:t.width,height:t.height,compression:s}}a(Os,"createKtx2");function on(e,t,r){let n=read(e);if(n.vkFormat!==VK_FORMAT_R8G8B8A8_UNORM)throw new Error("Text atlas must use RGBA8 KTX2.");if(n.pixelWidth<=0||n.pixelHeight<=0||n.levels.length!==1||n.levels[0]===void 0)throw new Error("Text atlas KTX2 dimensions or levels are invalid.");if(t!==void 0&&n.pixelWidth!==t)throw new Error("Text atlas KTX2 width does not match metrics.");if(r!==void 0&&n.pixelHeight!==r)throw new Error("Text atlas KTX2 height does not match metrics.");if(n.keyValue.KTXorientation!=="rd")throw new Error("Text atlas KTX2 orientation must be rd.");let o=n.levels[0],s,a;if(n.supercompressionScheme===KHR_SUPERCOMPRESSION_ZSTD){let c=nn().zstdDecompressSync;if(c===void 0)throw new Error("This Node.js runtime cannot validate Zstandard KTX2 text atlases.");s=c(o.levelData),a="zstd";}else if(n.supercompressionScheme===KHR_SUPERCOMPRESSION_NONE)s=o.levelData,a="none";else throw new Error("Text atlas uses an unsupported KTX2 supercompression scheme.");let i=n.pixelWidth*n.pixelHeight*4;if(s.byteLength!==i||o.uncompressedByteLength!==i)throw new Error("Text atlas KTX2 decoded byte length is invalid.");return {width:n.pixelWidth,height:n.pixelHeight,compression:a}}a(on,"validateKtx2Bytes");function Ur(e){return `${JSON.stringify(e)}
2
2
  `}a(Ur,"stableJson");function er(e,t,r){return {path:nr(e,t),sha256:f(r),bytes:r.byteLength}}a(er,"fileReceipt");function sn(e,t,r,n){return f(JSON.stringify({generator:it,fontKey:n,fontHash:e.sourceHash,glyphSetHash:t,options:r}))}a(sn,"createInputHash");async function Is(e,t,r,n,o,s,a){if(o.length===0)throw new Error(`Text font ${JSON.stringify(t)} covers no required glyphs.`);let i$1=qr.parse(rn(n.source)),c=await Ms(n.source,o,t,a),u=Fs(c.data,i$1,a),p=Buffer.from(Ur(u)),l=Os(c.png);if(c.data.common.scaleW!==l.width||c.data.common.scaleH!==l.height)throw new Error(`Text font ${JSON.stringify(t)} metrics and texture dimensions differ.`);let m=st(e,r.browser),f=st(e,r.atlas),h=st(e,r.metrics),y=tn(h),b={schemaVersion:or,generatorVersion:it,font:{key:t,source:n.description,sourceHash:n.sourceHash,...n.license===void 0?{}:{license:n.license}},inputHash:sn(n,s,a,t),glyphSetHash:s,codePoints:o,options:a,texture:{format:"RGBA8",orientation:"rd",compression:l.compression,width:l.width,height:l.height},files:{browser:er(e,m,n.browser),atlas:er(e,f,l.bytes),metrics:er(e,h,p)}},x=Buffer.from(Ur(b));await i(m,n.browser),await i(f,l.bytes),await i(h,p),await i(y,x);let R=[m,f,h,y].map(w=>nr(e,w));return {font:t,receipt:b,metadataPath:nr(e,y),updatedFiles:R}}a(Is,"generateRoute");async function Ls(e,t="three-blocks.text.ts",r={}){let n=await $t(e,t),o=await _t(e,n),s=Xr(n),a=[];for(let[p,l]of Object.entries(n.fonts).sort((m,f)=>m[0].localeCompare(f[0]))){let m=await As(e,l.source,r,"builtin"in l.source?st(e,l.browser):void 0),f=qr.parse(rn(m.source));a.push({key:p,route:l,resolved:m,font:f,codePoints:Cs(f,o.glyphs.codePoints)});}let i=new Set(a.flatMap(p=>p.codePoints)),c=o.glyphs.codePoints.filter(p=>!i.has(p));if(c.length>0)throw new Error(`Configured fonts do not cover ${c.length} required glyph(s): ${c.map(p=>String.fromCodePoint(p)).join(" ")}`);let u=[];for(let p of a)u.push(await Is(e,p.key,p.route,p.resolved,p.codePoints,o.glyphs.hash,s));return {glyphs:o.glyphs.codePoints.length,glyphSetHash:o.glyphs.hash,atlases:u,updatedFiles:u.flatMap(p=>p.updatedFiles)}}a(Ls,"generateTextAtlases");function tr(e,t){if(!a$1(e)||typeof e.path!="string"||typeof e.sha256!="string"||!/^[a-f0-9]{64}$/u.test(e.sha256)||!Number.isSafeInteger(e.bytes)||e.bytes<0)throw new Error(`${t} receipt is invalid.`);return e}a(tr,"parseFileReceipt");function an(e){if(!a$1(e)||e.schemaVersion!==or||e.generatorVersion!==it||!a$1(e.font)||typeof e.font.key!="string"||typeof e.font.source!="string"||typeof e.font.sourceHash!="string"||!/^[a-f0-9]{64}$/u.test(e.font.sourceHash)||typeof e.inputHash!="string"||!/^[a-f0-9]{64}$/u.test(e.inputHash)||typeof e.glyphSetHash!="string"||!/^[a-f0-9]{64}$/u.test(e.glyphSetHash)||!Array.isArray(e.codePoints)||!e.codePoints.every(t=>Number.isSafeInteger(t))||!a$1(e.options)||!a$1(e.texture)||!a$1(e.files))throw new Error("Text atlas generation metadata is invalid.");if(e.texture.format!=="RGBA8"||e.texture.orientation!=="rd"||!["zstd","none"].includes(e.texture.compression))throw new Error("Text atlas texture metadata is invalid.");return tr(e.files.browser,"Browser font"),tr(e.files.atlas,"Text atlas"),tr(e.files.metrics,"Text metrics"),e}a(an,"parseTextAtlasReceipt");function js(e){if(!a$1(e)||!a$1(e.atlas)||!Array.isArray(e.glyphs))throw new Error("Text metrics are invalid.");let t=Ee(e.atlas.width,"Text metrics atlas.width"),r=Ee(e.atlas.height,"Text metrics atlas.height"),n=e.glyphs.map((o,s)=>{if(!a$1(o))throw new Error(`Text metrics glyph ${s} is invalid.`);return Ee(o.unicode,`Text metrics glyph ${s}.unicode`)});return {width:t,height:r,codePoints:n}}a(js,"metricsCoverage");async function rr(e,t,r,n){let o=await l(e,z.join(e,t.path),r,n);if(o.data.byteLength!==t.bytes||f(o.data)!==t.sha256)throw new Error(`${n} checksum or byte length differs from generation metadata.`);return o.data}a(rr,"verifyReceiptFile");async function Ct(e,t="three-blocks.text.ts"){let r;try{r=await $t(e,t);}catch(n){return {state:"invalid",reason:`Text configuration is invalid: ${n instanceof Error?n.message:String(n)}`,missing:[],atlases:[]}}try{let n=await _t(e,r),o=Xr(r),s=[],a=new Set;for(let[c,u]of Object.entries(r.fonts).sort((p,l)=>p[0].localeCompare(l[0]))){let p=await l(e,tn(st(e,u.metrics)),d$1.metadata,"Text atlas generation metadata"),l$1=an(JSON.parse(p.data.toString("utf8")));if(l$1.font.key!==c)throw new Error(`Text atlas metadata belongs to ${JSON.stringify(l$1.font.key)}, not ${JSON.stringify(c)}.`);let m=await _s(e,u.source),f$1=sn(m,l$1.glyphSetHash,o,c);if(l$1.inputHash!==f$1)return {state:"invalid",reason:`Text atlas ${c} font source or generation options changed.`,missing:[],atlases:[...s,l$1]};let[h,y,b]=await Promise.all([rr(e,l$1.files.browser,d$1.texture,"Browser font"),rr(e,l$1.files.atlas,d$1.texture,"Text atlas"),rr(e,l$1.files.metrics,d$1.metrics,"Text metrics")]);if(f(h)!==m.browserHash)throw new Error(`Browser font ${c} differs from its resolved source.`);let x=js(JSON.parse(b.toString("utf8"))),R=on(y,x.width,x.height);if(R.width!==l$1.texture.width||R.height!==l$1.texture.height||R.compression!==l$1.texture.compression)throw new Error(`Text atlas ${c} texture metadata does not match KTX2.`);for(let w of x.codePoints)a.add(w);s.push(l$1);}let i=n.glyphs.codePoints.filter(c=>!a.has(c));return i.length>0?{state:"missing",reason:`${i.length} required glyph(s) are missing.`,missing:i,atlases:s}:{state:"ready",reason:`${n.glyphs.codePoints.length} required glyphs are covered by ${s.length} atlas(es).`,missing:[],atlases:s}}catch(n){return (typeof n=="object"&&n!==null&&"code"in n?n.code:void 0)==="ENOENT"?{state:"missing",reason:"Text atlas files or generation metadata are absent.",missing:[],atlases:[]}:{state:"invalid",reason:n instanceof Error?n.message:String(n),missing:[],atlases:[]}}}a(Ct,"inspectTextAtlases");var ir=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".wgsl",".glsl",".vert",".frag",".json",".css"],dr=new Set(ir),ar=/^(?:three-blocks\.shaders\.json|(?:precompile|three-blocks\.shaders)\.config\.(?:cjs|cts|js|mjs|mts|ts))$/u,Ds=/(?:^|\/)scene\.(?:cjs|cts|js|jsx|mjs|mts|ts|tsx)$/u,Hs=/\b(?:export\s+)?(?:async\s+)?function\s+createScene\b|\bcreateScene\s*=\s*(?:async\s*)?\(/u,Vs=/\b(?:[A-Za-z_$][\w$]*\.)*(?:shaders|shaderCache|sceneShaders)\s*\.\s*(?:material|pipeline|compute|container)\s*\(/u,Us=/\b(import|export)(?!\s*\()\s*(type\b\s*)?(?:[^"'();]*?\bfrom\s*)?["']([^"']+)["']/gu,Ws=/\bimport\s*\(\s*["']([^"']+)["']\s*\)/gu,Gs=/\b(?:import|export)(?!\s*\()\s*(?:[^"'();]*?\bfrom\s*)?["']([^"']+)["']|\bimport\s*\(\s*["']([^"']+)["']\s*\)/gu,zs=/^[0-9A-Za-z][0-9A-Za-z.+_-]{0,127}$/u,cr=4096,Ks="./shaders";function ln(e,t){let r=z.relative(e,t).split(z.sep).join("/");if(r.length===0||/[\u0000-\u001f\u007f]/u.test(r))throw new Error("Semantic input has an unsafe relative path.");return r}a(ln,"portableRelativePath");function lr(e,t){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{throw new Error(`Shader-relevant source ${JSON.stringify(t)} is not valid UTF-8.`)}}a(lr,"sourceText");function mr(e,t){let r="",n="code";for(let o=0;o<e.length;o++){let s=e[o]??"",a=e[o+1]??"";if(n==="code"){if(s==="/"&&a==="/"){r+=" ",n="line-comment",o++;continue}if(s==="/"&&a==="*"){r+=" ",n="block-comment",o++;continue}if(s==="'"||s==='"'||s==="`"){n=s==="'"?"single":s==='"'?"double":"template",r+=t?s:" ";continue}r+=s;continue}if(n==="line-comment"){s===`
3
3
  `?(r+=`
4
4
  `,n="code"):r+=" ";continue}if(n==="block-comment"){s==="*"&&a==="/"?(r+=" ",n="code",o++):r+=s===`
@@ -7,9 +7,9 @@ import {c,d,b as b$1}from'./chunk-LZX5NCGL.js';export{a as DOCUMENTED_BROWSER_NO
7
7
  `?`
8
8
  `:" ",s===i&&(n="code");}return r}a(mr,"lexicalSource");function qs(e){let t=new Set,r=mr(e,true);for(let n of r.matchAll(Us))n[2]===void 0&&n[3]!==void 0&&t.add(n[3]);for(let n of r.matchAll(Ws))n[1]!==void 0&&t.add(n[1]);return [...t].sort()}a(qs,"importSpecifiers");function Xs(e){let t=new Set;for(let r of mr(e,true).matchAll(Gs)){let n=r[1]??r[2];n!==void 0&&t.add(n);}return [...t].sort()}a(Xs,"runtimeSpecifiers");function un(e){return (e.split(/[?#]/u,1)[0]??e).replaceAll("\\","/")}a(un,"cleanSpecifier");function Js(e,t,r){let n=un(t),o;if(n.startsWith("./")||n.startsWith("../"))o=z.posix.normalize(z.posix.join(z.posix.dirname(e),n));else if(n.startsWith("@/"))o=`src/${n.slice(2)}`;else if(n.startsWith("/src/"))o=n.slice(1);else return;if(o===".three-blocks"||o.startsWith(".three-blocks/"))return;let s=z.posix.extname(o).toLowerCase(),a=new Set([o]);if(s.length===0||!dr.has(s)){for(let i of ir)a.add(`${o}${i}`);for(let i of ir)a.add(`${o}/index${i}`);}else if([".js",".mjs",".cjs",".jsx"].includes(s)){let i=o.slice(0,-s.length);for(let c of [".ts",".tsx",".mts",".cts"])a.add(`${i}${c}`);}return [...a].find(i=>r.has(i))}a(Js,"resolveProjectImport");function Zs(e,t){let r=mr(t,false);return Ds.test(e)||Hs.test(r)||Vs.test(r)}a(Zs,"isShaderRoot");async function Te(e,t){let r=await realpath(e);if(t!==void 0){let l$1={},m=0;for(let f$1 of t){let h=await l(r,z.join(r,f$1),d$1.semanticInput,"Declared shader semantic input");if(m+=h.data.byteLength,m>d$1.semanticTotal)throw new Error("Declared shader semantic inputs exceed the total inspection size limit.");l$1[f$1]=f(h.data);}return l$1}let n=new Map,o=z.join(r,"src");if(await g(o))for(let l$1 of await m(r,o,m=>dr.has(z.extname(m).toLowerCase()))){let m=await l(r,l$1,d$1.semanticInput,"Shader semantic input");n.set(ln(r,l$1),m.data);}for(let l$1 of await readdir(r,{withFileTypes:true})){if(!l$1.isFile()||!ar.test(l$1.name)&&!dr.has(z.extname(l$1.name).toLowerCase()))continue;let m=await l(r,z.join(r,l$1.name),d$1.semanticInput,ar.test(l$1.name)?"Shader configuration input":"Shader semantic input");n.set(l$1.name,m.data);}if(n.size>cr)throw new Error(`Shader input discovery exceeds the ${cr}-file limit.`);let s=new Set,a=new Map;for(let[l,m]of n){if(!l.includes("/")&&ar.test(l)&&s.add(l),!l.startsWith("src/"))continue;let f=lr(m,l);a.set(l,f),Zs(l,f)&&s.add(l);}if(s.size===0)throw new Error("No shader registration or scene source root was found.");let i=new Set,c=[...s].sort();for(;c.length>0;){let l=c.shift();if(l===void 0||i.has(l))continue;let m=n.get(l);if(m===void 0)continue;i.add(l);let f=a.get(l)??lr(m,l);for(let h of qs(f)){let y=Js(l,h,n);y!==void 0&&!i.has(y)&&c.push(y);}c.sort();}let u=0,p={};for(let l of [...i].sort()){let m=n.get(l);if(m===void 0)throw new Error(`Shader input ${JSON.stringify(l)} disappeared during inspection.`);if(u+=m.byteLength,u>d$1.semanticTotal)throw new Error("Semantic shader inputs exceed the total inspection size limit.");p[l]=f(m);}return p}a(Te,"snapshotShaderInputs");function ur(e){if(typeof e=="string")return e;if(a$1(e))return ur(e.import)??ur(e.default)}a(ur,"conditionalImportTarget");async function dn(e,t){let r=e;for(;;){let n=z.join(r,"node_modules",...t.split("/"),"package.json");if(await g(n)){let s=await j(n,d$1.packageJson,`${t} package.json`),a=JSON.parse(s.data.toString("utf8"));if(!a$1(a)||a.name!==t||typeof a.version!="string"||!zs.test(a.version))throw new Error(`Installed ${t} package metadata is invalid.`);return {root:z.dirname(s.path),manifest:a}}let o=z.dirname(r);if(o===r)break;r=o;}throw new Error(`Cannot verify the installed ${t} package.`)}a(dn,"findInstalledPackage");async function Ys(e,t){if(!a$1(t.exports))throw new Error("Installed three-blocks package has no public exports map.");let r=ur(t.exports[Ks]);if(r===void 0||!r.startsWith("./"))throw new Error("Installed three-blocks shader export has no import target.");let n=await realpath(e),o=[z.resolve(n,r)],s=new Map,a=0;for(;o.length>0;){let c=o.shift();if(c===void 0)break;let u=await j(c,d$1.semanticInput,"Three Blocks shader runtime module");if(!h(n,u.path)||u.path===n)throw new Error("Three Blocks shader runtime closure escapes its package.");let p=ln(n,u.path);if(s.has(p))continue;if(a+=u.data.byteLength,a>d$1.semanticTotal)throw new Error("Three Blocks shader runtime closure exceeds the inspection limit.");s.set(p,f(u.data));let l=lr(u.data,p);for(let m of Xs(l)){let f=un(m);if(!f.startsWith("./")&&!f.startsWith("../"))continue;let h$1=z.resolve(z.dirname(u.path),f);if(!h(n,h$1))throw new Error("Three Blocks shader runtime import escapes its package.");o.push(h$1);}if(o.sort(),s.size+o.length>cr)throw new Error("Three Blocks shader runtime closure exceeds the file limit.")}let i=[...s].sort((c,u)=>c[0].localeCompare(u[0])).map(([c,u])=>`${c}\0${u}`).join(`
9
9
  `);return f(i)}a(Ys,"shaderRuntimeClosure");async function we(e){let[t,r]=await Promise.all([dn(e,"three"),dn(e,"three-blocks")]);return {three:String(t.manifest.version),threeBlocks:String(r.manifest.version),threeBlocksShaderClosure:await Ys(r.root,r.manifest)}}a(we,"readInstalledShaderRuntime");function Qs(e,t){return e.render===t.render&&e.vertex===t.vertex&&e.fragment===t.fragment&&e.compute===t.compute}a(Qs,"sameCoverage");function ea(e){let t=e.some(n=>n.state==="invalid")?"invalid":e.some(n=>n.state==="missing")?"missing":e.some(n=>n.state==="stale")?"stale":"fresh",r=e.filter(n=>n.state===t);return {state:t,reason:t==="fresh"?`${e.length} configured shader scene${e.length===1?" is":"s are"} fresh.`:r.map(n=>`${n.scene}: ${n.reason}`).join("; ")}}a(ea,"classifyMatrix");function ta(e,t){let r=e.tool;if(!r)return "Shader receipt has no public tool compatibility metadata.";if(r.compatibility!==t)return "Shader receipt targets a different runtime compatibility contract.";if(r.transform!==x)return "Shader receipt uses a different provider transform version.";if(r.address!==SHADER_ADDRESS_SCHEMA_VERSION||r.recipe!==SHADER_RECIPE_SCHEMA_VERSION||r.hydration!==SHADER_HYDRATION_SCHEMA_VERSION)return "Shader receipt uses incompatible address, recipe, or hydration schemas."}a(ta,"exactToolCompatibility");function ra(e,t){let r=Object.keys(t).filter(s=>Object.hasOwn(e,s)&&e[s]!==t[s]),n=Object.keys(t).filter(s=>!Object.hasOwn(e,s)),o=Object.keys(e).filter(s=>!Object.hasOwn(t,s));return {...r.length>0?{changedInputs:r}:{},...n.length>0?{addedInputs:n}:{},...o.length>0?{removedInputs:o}:{}}}a(ra,"inputChanges");async function Fe(e=process.cwd(),t){let r$1=await r(e),n=await s(r$1),o$1=z.join(r$1,o),s$1=a(()=>({schemaVersion:1,root:r$1,state:"missing",reason:`${o}/meta.json is absent.`,scenes:n.scenes.map(a=>({scene:a.key,state:"missing",reason:"No committed shader receipt."}))}),"missing");if(!await g(o$1)||!await g(z.join(o$1,"meta.json")))return s$1();try{let a=await k(r$1,o$1,"Shader artifact directory"),i=await l(a,z.join(a,"meta.json"),d$1.receipt,"Shader receipt"),c=c$1(JSON.parse(i.data.toString("utf8"))),u=await G$1(a,i.data),p=t??await we(r$1),l$1=v(p.three),m=new Set(n.scenes.map(S=>S.key)),h=Object.keys(c.scenes).filter(S=>!m.has(S));if(h.length>0)throw new Error(`Shader receipt contains unconfigured scenes: ${h.join(", ")}.`);let y=ta(c,l$1);if(y)throw new Error(y);let b=c.runtime.three!==p.three||c.runtime.threeBlocks!==p.threeBlocks,x=c.runtime.threeBlocksShaderClosure!==p.threeBlocksShaderClosure,R=c.tool?.version!==w,w$1=z.join(r$1,n.publicDir??"public"),A=[];for(let S of n.scenes){let g=c.scenes[S.key];if(!g){A.push({scene:S.key,state:"missing",reason:"Scene is absent from the complete receipt matrix."});continue}let O=await l(a,z.join(a,g.artifact),d$1.manifest,"Shader manifest");if(f(O.data)!==g.artifactHash)throw new Error(`Shader artifact checksum differs for scene "${S.key}".`);if(g.asset!==void 0&&g.assetHash!==void 0){let re=await l(w$1,z.join(w$1,g.asset),d$1.manifest,"Static shader manifest");if(f(re.data)!==g.assetHash)throw new Error(`Static shader manifest checksum differs for scene "${S.key}".`)}if(g.bytes!==void 0&&g.bytes!==O.data.byteLength)throw new Error(`Shader artifact byte count differs for scene "${S.key}".`);let T=Et(O.data.toString("utf8"),O.path,S.key,{three:c.runtime.three,threeBlocks:c.runtime.threeBlocks,compatibility:l$1,address:SHADER_ADDRESS_SCHEMA_VERSION,recipe:SHADER_RECIPE_SCHEMA_VERSION,hydration:SHADER_HYDRATION_SCHEMA_VERSION});if(!Qs(T,g.coverage))throw new Error(`Shader coverage differs for scene "${S.key}".`);if(!n.allowLiveBuilds&&g.skipped&&g.skipped.render+g.skipped.compute>0)throw new Error(`Scene "${S.key}" contains skipped live builds but allowLiveBuilds is false.`);let N=await Te(r$1,S.inputs),E=ra(g.inputs,N),v=(E.changedInputs?.length??0)+(E.addedInputs?.length??0)+(E.removedInputs?.length??0),$=b||x||R||v>0,L=u?.scenes[S.key],D=L===void 0||u===void 0?void 0:{...L,schemaVersion:u.schemaVersion,measuredAt:u.measuredAt,source:u.source,...u.source==="committed-capture"?{adapter:u.adapter,platform:u.platform}:{}};A.push({scene:S.key,state:$?"stale":"fresh",reason:b?"Installed runtime versions differ from the receipt.":x?"Installed three-blocks/shaders runtime closure differs from the receipt.":R?`Receipt was generated by @three-blocks/devtools ${c.tool?.version??"unknown"}.`:v>0?`${v} semantic shader input${v===1?"":"s"} changed.`:"Manifest, runtime, schemas, transform, and semantic inputs match.",coverage:T,...!$&&D!==void 0&&D.builds===T.render+T.compute?{timing:D}:{},...E});}let C=ea(A),K=C.state==="fresh"&&u!==void 0&&A.every(S=>S.timing!==void 0)?u:void 0;return {schemaVersion:1,root:r$1,...C,scenes:A,runtime:p,receipt:c,...K===void 0?{}:{timing:K}}}catch(a){let i=a instanceof Error?a.message:String(a);return {schemaVersion:1,root:r$1,state:"invalid",reason:i,scenes:n.scenes.map(c=>({scene:c.key,state:"invalid",reason:i}))}}}a(Fe,"inspectShaderMatrix");var wn=".three-blocks/shaders/pending-capture";function sa(e){return (e instanceof Error?`${e.name}: ${e.message}`:String(e)).includes("ShaderHydrationError:")}a(sa,"isShaderHydrationFailure");async function aa(e,t,r){if(t.length===0)return;let n=z.join(e,o,"meta.json"),o$1=await readFile(n);if(f(o$1)!==f(r))throw new Error("Shader receipt changed before failed scenes could be marked for recapture.");let s=c$1(JSON.parse(o$1.toString("utf8"))),a=f(r),i$1=new Set(t),c=c$1({...s,scenes:Object.fromEntries(Object.entries(s.scenes).map(([u,p])=>[u,i$1.has(u)?{...p,inputs:{...p.inputs,[wn]:a}}:p]))});await i(n,`${D(c)}
10
- `);}a(aa,"markShaderScenesForRecapture");function ia(e,t){return D(e)===D(t)}a(ia,"equalSnapshot");async function hr(e={}){let t$1=e.root?await realpath(e.root):await r(e.start),r$1=e.config===void 0?await u(t$1):void 0,n=e.config??r$1?.config??await s(t$1),o=e.runtime??await we(t$1),s$1=n.scenes,a$1,i={},c;if(e.ifStale){let T=await Fe(t$1,o);if(T.state==="fresh"&&T.scenes.every(N=>N.timing!==void 0))return {schemaVersion:1,root:t$1,skipped:true,reason:T.reason,scenes:[]};if(T.state!=="invalid"&&T.receipt!==void 0){let N=T.state==="fresh";s$1=n.scenes.filter(E=>{let v=T.scenes.find($=>$.scene===E.key);return v?.state!=="fresh"||N&&v.timing===void 0}),a$1=T.receipt;for(let E of T.scenes){if(E.state!=="fresh"||E.timing===void 0)continue;let{builds:v,liveBuildMs:$,precompiledBuildMs:L,avoidedBuildMs:D,runs:re,spreadMs:oe}=E.timing;i[E.scene]={builds:v,liveBuildMs:$,precompiledBuildMs:L,avoidedBuildMs:D,runs:re,spreadMs:oe},E.timing.source==="committed-capture"&&E.timing.adapter!==void 0&&E.timing.platform!==void 0&&(c={adapter:E.timing.adapter,platform:E.timing.platform});}}}let u$1=performance.now(),p=a$1!==void 0&&(a$1.runtime.three!==o.three||a$1.runtime.threeBlocks!==o.threeBlocks||a$1.runtime.threeBlocksShaderClosure!==o.threeBlocksShaderClosure||a$1.tool?.version!==w)?f(D({runtime:a$1.runtime,tool:a$1.tool})):void 0,l=a(async()=>new Map(await Promise.all(n.scenes.map(async T=>[T.key,await Te(t$1,T.inputs)]))),"snapshotInputs"),m=await l(),f$1=a(async()=>{let T=await l();for(let N of n.scenes){let E=m.get(N.key),v=T.get(N.key);if(E===void 0||v===void 0||!ia(E,v))throw new Error(`Semantic shader inputs changed during capture for scene "${N.key}"; the current scene was not committed.`)}},"assertInputsUnchanged"),h=e.driver===void 0,y=e.driver===void 0&&e.driverKind===void 0&&e.serve===void 0&&e.url===void 0?await t(t$1):void 0,b=e.serve??y?.serve,x=e.driverKind??y?.driverKind??(b===void 0?"vite":"static");if(e.url!==void 0&&(e.serve!==void 0||e.driverKind!==void 0))throw new Error("--url cannot be combined with --driver or --serve.");if(x==="vite"&&b!==void 0)throw new Error("--serve requires the static shader driver.");if(x==="static"&&b===void 0&&e.driver===void 0)throw new Error("The static shader driver requires --serve <built-directory>.");let R=e.driver===void 0?await import('./shader-browser-C2YETRGE.js'):void 0,w$1=e.driver??(e.url!==void 0?R.createAttachedPlaywrightShaderDriver({root:t$1,runtime:o,url:e.url,...e.headed!==void 0?{headed:e.headed}:{}}):x==="static"?R.createStaticPlaywrightShaderDriver({root:t$1,runtime:o,serve:b,...e.headed!==void 0?{headed:e.headed}:{}}):R.createPlaywrightShaderDriver({root:t$1,runtime:o,...e.headed!==void 0?{headed:e.headed}:{}})),A=new Map,C$1=[],K=a$1!==void 0&&n.scenes.every(T=>a$1?.scenes[T.key]!==void 0),S=a$1,g,O=e.attempts??2;if(!Number.isSafeInteger(O)||O<1||O>5)throw new Error("Shader capture attempts must be an integer in 1...5.");try{for(let[v,$]of s$1.entries()){e.onSceneStart?.($.key,v,s$1.length);let L,D,re=0;for(;re<O;re++)try{if(L=C(await w$1.capture($,n),{scene:$.key,runtime:o}),L.skipped.length>0&&!n.allowLiveBuilds)throw new Error(`Scene "${$.key}" contains ${L.skipped.length} unregistered live shader build${L.skipped.length===1?"":"s"} while allowLiveBuilds is false.`);break}catch(oe){D=oe,L=void 0,re+1<O&&e.onSceneRetry?.($.key,re+2,O,n.timeoutMs,oe);}if(!L)throw new Error(`Shader capture "${$.key}" failed after ${O} attempts: ${D instanceof Error?D.message:String(D)}`);if(A.set($.key,L),C$1.push({scene:$.key,attempts:re+1,coverage:L.coverage,skipped:L.skipped.length,startupBuilds:L.stats.registeredBuilds,startupBuildMs:L.stats.buildMs,...L.timing===void 0?{}:{timing:L.timing}}),K&&S!==void 0){await f$1();let oe=new Map(n.scenes.map(se=>{let be=se.key===$.key?m.get(se.key):S?.scenes[se.key]?.inputs;if(be===void 0)throw new Error(`Shader checkpoint is missing scene "${se.key}".`);return p!==void 0&&!A.has(se.key)&&(be={...be,[wn]:p}),[se.key,be]}));g=await N({root:t$1,scenes:n.scenes,captures:new Map([[$.key,L]]),runtime:o,inputs:oe,previousReceipt:S,publicDirectory:n.publicDir??"public"}),S=g.receipt;}}await f$1(),g??=await N({root:t$1,scenes:n.scenes,captures:A,runtime:o,inputs:m,...a$1===void 0?{}:{previousReceipt:a$1},publicDirectory:n.publicDir??"public"});let T={...i};for(let v of C$1)T[v.scene]={builds:v.coverage.render+v.coverage.compute,setupMeasured:!1,liveBuildMs:v.startupBuildMs,precompiledBuildMs:0,avoidedBuildMs:v.startupBuildMs,runs:1,spreadMs:0};if(e.commitTiming===!0){let v=c??{adapter:A.values().next().value?.provenance?.adapter??"WebGPU adapter",platform:`${Mt.platform()}/${Mt.arch()}`};await M$1(t$1,T,await(w$1.timingEnvironment?.()??v));}else await J(t$1,T);let N$1=await readFile(z.join(g.directory,"meta.json")),E=await G$1(g.directory,N$1);return {schemaVersion:1,root:t$1,skipped:!1,reason:`Wrote ${C$1.length} shader scene${C$1.length===1?"":"s"}.`,durationMs:performance.now()-u$1,scenes:C$1,measurement:{beforeBuilds:C$1.reduce((v,$)=>v+$.startupBuilds,0),afterBuilds:0,firstFrameDeltaMs:-C$1.reduce((v,$)=>v+$.startupBuildMs,0),source:"capture-build-phase"},...r$1===void 0?{}:{configuration:{created:r$1.created,file:r$1.file}},written:g,...E===void 0?{}:{timing:E}}}finally{h&&await w$1.close();}}a(hr,"captureShaders");function da(e){return ["workerReady","assetsReady",...e.requiresText?["textReady"]:[],"compileEnd","firstFrame"]}a(da,"requiredReadiness");function yn(e){if(e.length===0)throw new Error("Cannot take the median of an empty shader timing capture.");let t=[...e].sort((s,a)=>s-a),r=Math.floor(t.length/2),n=t[r];if(n===void 0)throw new Error("Shader timing median is unavailable.");if(t.length%2===1)return n;let o=t[r-1];if(o===void 0)throw new Error("Shader timing median pair is unavailable.");return (o+n)/2}a(yn,"median");function fr(e,t,r,n){if(e.scene!==t.key||e.mode!==r)throw new Error(`Browser observation identity differs for scene "${t.key}".`);if(e.compatibility!==n||e.transform!==x)throw new Error(`Browser observation compatibility differs for scene "${t.key}".`);let o=da(t).filter(s=>e.readiness[s]!==true);if(o.length>0)throw new Error(`Scene "${t.key}" ${r} observation is missing readiness bits: ${o.join(", ")}.`);if(e.errors.length>0)throw new Error(`Scene "${t.key}" ${r} browser errors:
10
+ `);}a(aa,"markShaderScenesForRecapture");function ia(e,t){return D(e)===D(t)}a(ia,"equalSnapshot");async function hr(e={}){let t$1=e.root?await realpath(e.root):await r(e.start),r$1=e.config===void 0?await u(t$1):void 0,n=e.config??r$1?.config??await s(t$1),o=e.runtime??await we(t$1),s$1=n.scenes,a$1,i={},c;if(e.ifStale){let T=await Fe(t$1,o);if(T.state==="fresh"&&T.scenes.every(N=>N.timing!==void 0))return {schemaVersion:1,root:t$1,skipped:true,reason:T.reason,scenes:[]};if(T.state!=="invalid"&&T.receipt!==void 0){let N=T.state==="fresh";s$1=n.scenes.filter(E=>{let v=T.scenes.find($=>$.scene===E.key);return v?.state!=="fresh"||N&&v.timing===void 0}),a$1=T.receipt;for(let E of T.scenes){if(E.state!=="fresh"||E.timing===void 0)continue;let{builds:v,liveBuildMs:$,precompiledBuildMs:L,avoidedBuildMs:D,runs:re,spreadMs:oe}=E.timing;i[E.scene]={builds:v,liveBuildMs:$,precompiledBuildMs:L,avoidedBuildMs:D,runs:re,spreadMs:oe},E.timing.source==="committed-capture"&&E.timing.adapter!==void 0&&E.timing.platform!==void 0&&(c={adapter:E.timing.adapter,platform:E.timing.platform});}}}let u$1=performance.now(),p=a$1!==void 0&&(a$1.runtime.three!==o.three||a$1.runtime.threeBlocks!==o.threeBlocks||a$1.runtime.threeBlocksShaderClosure!==o.threeBlocksShaderClosure||a$1.tool?.version!==w)?f(D({runtime:a$1.runtime,tool:a$1.tool})):void 0,l=a(async()=>new Map(await Promise.all(n.scenes.map(async T=>[T.key,await Te(t$1,T.inputs)]))),"snapshotInputs"),m=await l(),f$1=a(async()=>{let T=await l();for(let N of n.scenes){let E=m.get(N.key),v=T.get(N.key);if(E===void 0||v===void 0||!ia(E,v))throw new Error(`Semantic shader inputs changed during capture for scene "${N.key}"; the current scene was not committed.`)}},"assertInputsUnchanged"),h=e.driver===void 0,y=e.driver===void 0&&e.driverKind===void 0&&e.serve===void 0&&e.url===void 0?await t(t$1):void 0,b=e.serve??y?.serve,x=e.driverKind??y?.driverKind??(b===void 0?"vite":"static");if(e.url!==void 0&&(e.serve!==void 0||e.driverKind!==void 0))throw new Error("--url cannot be combined with --driver or --serve.");if(x==="vite"&&b!==void 0)throw new Error("--serve requires the static shader driver.");if(x==="static"&&b===void 0&&e.driver===void 0)throw new Error("The static shader driver requires --serve <built-directory>.");let R=e.driver===void 0?await import('./shader-browser-ZCKOOMQ3.js'):void 0,w$1=e.driver??(e.url!==void 0?R.createAttachedPlaywrightShaderDriver({root:t$1,runtime:o,url:e.url,...e.headed!==void 0?{headed:e.headed}:{}}):x==="static"?R.createStaticPlaywrightShaderDriver({root:t$1,runtime:o,serve:b,...e.headed!==void 0?{headed:e.headed}:{}}):R.createPlaywrightShaderDriver({root:t$1,runtime:o,...e.headed!==void 0?{headed:e.headed}:{}})),A=new Map,C$1=[],K=a$1!==void 0&&n.scenes.every(T=>a$1?.scenes[T.key]!==void 0),S=a$1,g,O=e.attempts??2;if(!Number.isSafeInteger(O)||O<1||O>5)throw new Error("Shader capture attempts must be an integer in 1...5.");try{for(let[v,$]of s$1.entries()){e.onSceneStart?.($.key,v,s$1.length);let L,D,re=0;for(;re<O;re++)try{if(L=C(await w$1.capture($,n),{scene:$.key,runtime:o}),L.skipped.length>0&&!n.allowLiveBuilds)throw new Error(`Scene "${$.key}" contains ${L.skipped.length} unregistered live shader build${L.skipped.length===1?"":"s"} while allowLiveBuilds is false.`);break}catch(oe){D=oe,L=void 0,re+1<O&&e.onSceneRetry?.($.key,re+2,O,n.timeoutMs,oe);}if(!L)throw new Error(`Shader capture "${$.key}" failed after ${O} attempts: ${D instanceof Error?D.message:String(D)}`);if(A.set($.key,L),C$1.push({scene:$.key,attempts:re+1,coverage:L.coverage,skipped:L.skipped.length,startupBuilds:L.stats.registeredBuilds,startupBuildMs:L.stats.buildMs,...L.timing===void 0?{}:{timing:L.timing}}),K&&S!==void 0){await f$1();let oe=new Map(n.scenes.map(se=>{let be=se.key===$.key?m.get(se.key):S?.scenes[se.key]?.inputs;if(be===void 0)throw new Error(`Shader checkpoint is missing scene "${se.key}".`);return p!==void 0&&!A.has(se.key)&&(be={...be,[wn]:p}),[se.key,be]}));g=await N({root:t$1,scenes:n.scenes,captures:new Map([[$.key,L]]),runtime:o,inputs:oe,previousReceipt:S,publicDirectory:n.publicDir??"public"}),S=g.receipt;}}await f$1(),g??=await N({root:t$1,scenes:n.scenes,captures:A,runtime:o,inputs:m,...a$1===void 0?{}:{previousReceipt:a$1},publicDirectory:n.publicDir??"public"});let T={...i};for(let v of C$1)T[v.scene]={builds:v.coverage.render+v.coverage.compute,setupMeasured:!1,liveBuildMs:v.startupBuildMs,precompiledBuildMs:0,avoidedBuildMs:v.startupBuildMs,runs:1,spreadMs:0};if(e.commitTiming===!0){let v=c??{adapter:A.values().next().value?.provenance?.adapter??"WebGPU adapter",platform:`${Mt.platform()}/${Mt.arch()}`};await M$1(t$1,T,await(w$1.timingEnvironment?.()??v));}else await J(t$1,T);let N$1=await readFile(z.join(g.directory,"meta.json")),E=await G$1(g.directory,N$1);return {schemaVersion:1,root:t$1,skipped:!1,reason:`Wrote ${C$1.length} shader scene${C$1.length===1?"":"s"}.`,durationMs:performance.now()-u$1,scenes:C$1,measurement:{beforeBuilds:C$1.reduce((v,$)=>v+$.startupBuilds,0),afterBuilds:0,firstFrameDeltaMs:-C$1.reduce((v,$)=>v+$.startupBuildMs,0),source:"capture-build-phase"},...r$1===void 0?{}:{configuration:{created:r$1.created,file:r$1.file}},written:g,...E===void 0?{}:{timing:E}}}finally{h&&await w$1.close();}}a(hr,"captureShaders");function da(e){return ["workerReady","assetsReady",...e.requiresText?["textReady"]:[],"compileEnd","firstFrame"]}a(da,"requiredReadiness");function yn(e){if(e.length===0)throw new Error("Cannot take the median of an empty shader timing capture.");let t=[...e].sort((s,a)=>s-a),r=Math.floor(t.length/2),n=t[r];if(n===void 0)throw new Error("Shader timing median is unavailable.");if(t.length%2===1)return n;let o=t[r-1];if(o===void 0)throw new Error("Shader timing median pair is unavailable.");return (o+n)/2}a(yn,"median");function fr(e,t,r,n){if(e.scene!==t.key||e.mode!==r)throw new Error(`Browser observation identity differs for scene "${t.key}".`);if(e.compatibility!==n||e.transform!==x)throw new Error(`Browser observation compatibility differs for scene "${t.key}".`);let o=da(t).filter(s=>e.readiness[s]!==true);if(o.length>0)throw new Error(`Scene "${t.key}" ${r} observation is missing readiness bits: ${o.join(", ")}.`);if(e.errors.length>0)throw new Error(`Scene "${t.key}" ${r} browser errors:
11
11
  - ${e.errors.join(`
12
- - `)}`)}a(fr,"assertObservation");function ca(e,t,r,n){if(t.render>0&&r.stats.registeredRenderBuilds===0)throw new Error(`Scene "${e.key}" live baseline exercised no registered render pipeline.`);if(t.compute>0&&r.stats.registeredComputeBuilds===0)throw new Error(`Scene "${e.key}" live baseline exercised no registered compute kernel.`);bn(e,t,n);}a(ca,"assertZeroBuild");function bn(e,t,r){if(r.stats.registeredRenderBuilds!==0||r.stats.registeredComputeBuilds!==0){let n=r.stats.missedKeys??[];throw new Error(`Scene "${e.key}" injected path performed ${r.stats.registeredRenderBuilds} render and ${r.stats.registeredComputeBuilds} compute registered live builds.`+(n.length>0?` Missed keys: ${n.join(", ")}.`:""))}if(t.render>0&&r.stats.injectedRender===0)throw new Error(`Scene "${e.key}" injected no render entries.`);if(t.compute>0&&r.stats.injectedCompute===0)throw new Error(`Scene "${e.key}" injected no compute entries.`);if(r.stats.missed!==0||r.stats.missedRender!==0||r.stats.missedCompute!==0)throw new Error(`Scene "${e.key}" injected path reported shader manifest misses.`)}a(bn,"assertPrecompiledZeroBuild");async function la(e,t,r,n,o){let s=z.join(e,p);if(await g(s)){let i=await lstat(s);if(i.isSymbolicLink()||!i.isDirectory())throw new Error("Shader parity artifact directory is not a real directory.")}else await mkdir(s,{recursive:true});let a=[`${t}.live.png`,`${t}.precompiled.png`,`${t}.diff.png`];return await Promise.all([r,n,o].map(async(i,c)=>{let u=a[c];if(u===void 0)throw new Error("Parity artifact mapping failed.");let p=z.join(s,u);if(await g(p)){let l=await lstat(p);if(l.isSymbolicLink()||!l.isFile())throw new Error(`Shader parity target is not a regular file: ${u}.`)}await writeFile(p,i,{mode:384});})),a.map(i=>`${p}/${i}`)}a(la,"writeParityFailure");async function ua(e={}){let t$1=e.root?await realpath(e.root):await r(e.start),r$1=e.runtime??await we(t$1),n=v(r$1.three),o$1=await Fe(t$1,r$1);if(o$1.state!=="fresh")throw new Error(`Shader no-GPU validation is ${o$1.state}: ${o$1.reason}`);if(e.skipBrowser)return {schemaVersion:1,root:t$1,noGpu:o$1,browser:"skipped",scenes:[]};if(e.parityOnly===true&&e.commitTiming===true)throw new Error("Parity-only shader verification cannot commit timing.");let s$1=e.runs??5;if(!Number.isSafeInteger(s$1)||s$1<1||s$1>100)throw new Error("Shader timing runs must be an integer in 1...100.");let a$1=e.config??await s(t$1),i=await readFile(z.join(t$1,o,"meta.json")),c=c$1(JSON.parse(i.toString("utf8")));if(o$1.receipt===void 0||D(c)!==D(o$1.receipt))throw new Error("Shader receipt changed after no-GPU validation; restart browser parity verification.");let u=e.driver===void 0,p=e.driver===void 0&&e.driverKind===void 0&&e.serve===void 0&&e.url===void 0?await t(t$1):void 0,l=e.serve??p?.serve,m=e.driverKind??p?.driverKind??(l===void 0?"vite":"static");if(e.url!==void 0&&(e.serve!==void 0||e.driverKind!==void 0))throw new Error("--url cannot be combined with --driver or --serve.");if(m==="vite"&&l!==void 0)throw new Error("--serve requires the static shader driver.");if(m==="static"&&l===void 0&&e.driver===void 0)throw new Error("The static shader driver requires --serve <built-directory>.");let f=e.driver===void 0?await import('./shader-browser-C2YETRGE.js'):void 0,{compareShaderScreenshots:h}=await import('./shader-parity-QXJWR6OZ.js'),y=a(()=>e.url!==void 0?f.createAttachedPlaywrightShaderDriver({root:t$1,runtime:r$1,url:e.url,...e.headed!==void 0?{headed:e.headed}:{}}):m==="static"?f.createStaticPlaywrightShaderDriver({root:t$1,runtime:r$1,serve:l,...e.headed!==void 0?{headed:e.headed}:{}}):f.createPlaywrightShaderDriver({root:t$1,runtime:r$1,...e.headed!==void 0?{headed:e.headed}:{}}),"createDriver"),b=e.driver??y(),x=e.driver??y();await L(t$1,a$1.scenes.map(K=>K.key),i);let R=[],w={},A=[],C=new Set;try{for(let[S,g]of a$1.scenes.entries()){e.onSceneStart?.(g.key,S,a$1.scenes.length);let O=o$1.scenes.find(X=>X.scene===g.key);if(!O?.coverage)throw new Error(`Fresh receipt has no coverage for scene "${g.key}".`);let T=O.coverage,N=a(async X=>{let _e=X?"live":"precompiled",ce=X?"precompiled":"live",fe=X?b:x,De=X?x:b,le=await fe.observe(g,_e,a$1),He=await De.observe(g,ce,a$1,le.frame),j=le.mode==="live"?le:He,Se=le.mode==="precompiled"?le:He;fr(j,g,"live",n),fr(Se,g,"precompiled",n),ca(g,T,j,Se);let ft=a(async(H,J,Z)=>{let q=h(J,Z,a$1.parity.channelTolerance,g.maxDiffRatio??a$1.parity.maxDiffRatio);if(q.matches)return q;let Ht=await la(t$1,g.key,J,Z,q.diff),pe=q.nonBlack?`${q.differentPixels}/${q.totalPixels} pixels differ (${(q.diffRatio*100).toFixed(3)}%).`:`rendered output is black (live=${q.baselineLuminance.toFixed(4)}, precompiled=${q.precompiledLuminance.toFixed(4)}).`;throw new Error(`Shader ${H} parity failed for scene "${g.key}" at completed frames live=${j.frame}, precompiled=${Se.frame}: ${pe} Artifacts: ${Ht.join(", ")}`)},"compare");await ft("first frame",j.firstFrameScreenshot,Se.firstFrameScreenshot);let I=await ft("settled",j.screenshot,Se.screenshot);return {live:j,precompiled:Se,parity:I}},"observePair"),E,v,$;if(e.parityOnly===!0)try{E=await N(!0);}catch(X){sa(X)&&C.add(g.key),A.push({scene:g.key,error:X}),e.onSceneError?.(g.key,X);continue}else {await N(!0);let X=[];for(let j=0;j<s$1;j++)X.push(await N(j%2===0));let _e=X[X.length-1];if(_e===void 0)throw new Error(`Shader timing produced no runs for scene "${g.key}".`);if(E=_e,v=await x.observePublished(g,a$1),fr(v,g,"precompiled",n),bn(g,T,v),$=g.runtimeMotion?h(v.beforeScreenshot,v.screenshot,a$1.parity.channelTolerance,1):void 0,$&&$.diffRatio<1e-4)throw new Error(`Published scene "${g.key}" stopped animating during its normal 120-frame soak (changed ${$.differentPixels}/${$.totalPixels} canvas pixels).`);let ce=a(j=>j.stats.buildMs+(j.stats.precompiledSetupMs??0)+(j.stats.hydrationMs??0),"observedNodeBuilderMs"),fe=yn(X.map(j=>ce(j.live))),De=yn(X.map(j=>ce(j.precompiled))),le=Math.max(0,fe-De),He=X.map(j=>Math.max(0,ce(j.live)-ce(j.precompiled)));w[g.key]={builds:T.render+T.compute,setupMeasured:!0,liveBuildMs:fe,precompiledBuildMs:De,avoidedBuildMs:le,runs:s$1,spreadMs:Math.max(...He.map(j=>Math.abs(j-le)))};}let{diff:L,...D}=E.parity,{firstFrameScreenshot:re,screenshot:oe,...se}=E.live,{firstFrameScreenshot:be,screenshot:Pr,...mt}=E.precompiled,Ye;if(v!==void 0){let{beforeScreenshot:X,firstFrameScreenshot:_e,screenshot:ce,...fe}=v;Ye=fe;}R.push({scene:g.key,coverage:T,live:se,precompiled:mt,...Ye===void 0?{}:{published:Ye},parity:D,...$===void 0?{}:{runtimeMotion:{differentPixels:$.differentPixels,totalPixels:$.totalPixels,diffRatio:$.diffRatio}}}),await K(t$1,[g.key],i);}if(e.parityOnly===!0){if(await aa(t$1,[...C],i),A.length>0)throw new Error(`Shader parity failed for ${A.length}/${a$1.scenes.length} scene(s):
12
+ - `)}`)}a(fr,"assertObservation");function ca(e,t,r,n){if(t.render>0&&r.stats.registeredRenderBuilds===0)throw new Error(`Scene "${e.key}" live baseline exercised no registered render pipeline.`);if(t.compute>0&&r.stats.registeredComputeBuilds===0)throw new Error(`Scene "${e.key}" live baseline exercised no registered compute kernel.`);bn(e,t,n);}a(ca,"assertZeroBuild");function bn(e,t,r){if(r.stats.registeredRenderBuilds!==0||r.stats.registeredComputeBuilds!==0){let n=r.stats.missedKeys??[];throw new Error(`Scene "${e.key}" injected path performed ${r.stats.registeredRenderBuilds} render and ${r.stats.registeredComputeBuilds} compute registered live builds.`+(n.length>0?` Missed keys: ${n.join(", ")}.`:""))}if(t.render>0&&r.stats.injectedRender===0)throw new Error(`Scene "${e.key}" injected no render entries.`);if(t.compute>0&&r.stats.injectedCompute===0)throw new Error(`Scene "${e.key}" injected no compute entries.`);if(r.stats.missed!==0||r.stats.missedRender!==0||r.stats.missedCompute!==0)throw new Error(`Scene "${e.key}" injected path reported shader manifest misses.`)}a(bn,"assertPrecompiledZeroBuild");async function la(e,t,r,n,o){let s=z.join(e,p);if(await g(s)){let i=await lstat(s);if(i.isSymbolicLink()||!i.isDirectory())throw new Error("Shader parity artifact directory is not a real directory.")}else await mkdir(s,{recursive:true});let a=[`${t}.live.png`,`${t}.precompiled.png`,`${t}.diff.png`];return await Promise.all([r,n,o].map(async(i,c)=>{let u=a[c];if(u===void 0)throw new Error("Parity artifact mapping failed.");let p=z.join(s,u);if(await g(p)){let l=await lstat(p);if(l.isSymbolicLink()||!l.isFile())throw new Error(`Shader parity target is not a regular file: ${u}.`)}await writeFile(p,i,{mode:384});})),a.map(i=>`${p}/${i}`)}a(la,"writeParityFailure");async function ua(e={}){let t$1=e.root?await realpath(e.root):await r(e.start),r$1=e.runtime??await we(t$1),n=v(r$1.three),o$1=await Fe(t$1,r$1);if(o$1.state!=="fresh")throw new Error(`Shader no-GPU validation is ${o$1.state}: ${o$1.reason}`);if(e.skipBrowser)return {schemaVersion:1,root:t$1,noGpu:o$1,browser:"skipped",scenes:[]};if(e.parityOnly===true&&e.commitTiming===true)throw new Error("Parity-only shader verification cannot commit timing.");let s$1=e.runs??5;if(!Number.isSafeInteger(s$1)||s$1<1||s$1>100)throw new Error("Shader timing runs must be an integer in 1...100.");let a$1=e.config??await s(t$1),i=await readFile(z.join(t$1,o,"meta.json")),c=c$1(JSON.parse(i.toString("utf8")));if(o$1.receipt===void 0||D(c)!==D(o$1.receipt))throw new Error("Shader receipt changed after no-GPU validation; restart browser parity verification.");let u=e.driver===void 0,p=e.driver===void 0&&e.driverKind===void 0&&e.serve===void 0&&e.url===void 0?await t(t$1):void 0,l=e.serve??p?.serve,m=e.driverKind??p?.driverKind??(l===void 0?"vite":"static");if(e.url!==void 0&&(e.serve!==void 0||e.driverKind!==void 0))throw new Error("--url cannot be combined with --driver or --serve.");if(m==="vite"&&l!==void 0)throw new Error("--serve requires the static shader driver.");if(m==="static"&&l===void 0&&e.driver===void 0)throw new Error("The static shader driver requires --serve <built-directory>.");let f=e.driver===void 0?await import('./shader-browser-ZCKOOMQ3.js'):void 0,{compareShaderScreenshots:h}=await import('./shader-parity-QXJWR6OZ.js'),y=a(()=>e.url!==void 0?f.createAttachedPlaywrightShaderDriver({root:t$1,runtime:r$1,url:e.url,...e.headed!==void 0?{headed:e.headed}:{}}):m==="static"?f.createStaticPlaywrightShaderDriver({root:t$1,runtime:r$1,serve:l,...e.headed!==void 0?{headed:e.headed}:{}}):f.createPlaywrightShaderDriver({root:t$1,runtime:r$1,...e.headed!==void 0?{headed:e.headed}:{}}),"createDriver"),b=e.driver??y(),x=e.driver??y();await L(t$1,a$1.scenes.map(K=>K.key),i);let R=[],w={},A=[],C=new Set;try{for(let[S,g]of a$1.scenes.entries()){e.onSceneStart?.(g.key,S,a$1.scenes.length);let O=o$1.scenes.find(X=>X.scene===g.key);if(!O?.coverage)throw new Error(`Fresh receipt has no coverage for scene "${g.key}".`);let T=O.coverage,N=a(async X=>{let _e=X?"live":"precompiled",ce=X?"precompiled":"live",fe=X?b:x,De=X?x:b,le=await fe.observe(g,_e,a$1),He=await De.observe(g,ce,a$1,le.frame),j=le.mode==="live"?le:He,Se=le.mode==="precompiled"?le:He;fr(j,g,"live",n),fr(Se,g,"precompiled",n),ca(g,T,j,Se);let ft=a(async(H,J,Z)=>{let q=h(J,Z,a$1.parity.channelTolerance,g.maxDiffRatio??a$1.parity.maxDiffRatio);if(q.matches)return q;let Ht=await la(t$1,g.key,J,Z,q.diff),pe=q.nonBlack?`${q.differentPixels}/${q.totalPixels} pixels differ (${(q.diffRatio*100).toFixed(3)}%).`:`rendered output is black (live=${q.baselineLuminance.toFixed(4)}, precompiled=${q.precompiledLuminance.toFixed(4)}).`;throw new Error(`Shader ${H} parity failed for scene "${g.key}" at completed frames live=${j.frame}, precompiled=${Se.frame}: ${pe} Artifacts: ${Ht.join(", ")}`)},"compare");await ft("first frame",j.firstFrameScreenshot,Se.firstFrameScreenshot);let I=await ft("settled",j.screenshot,Se.screenshot);return {live:j,precompiled:Se,parity:I}},"observePair"),E,v,$;if(e.parityOnly===!0)try{E=await N(!0);}catch(X){sa(X)&&C.add(g.key),A.push({scene:g.key,error:X}),e.onSceneError?.(g.key,X);continue}else {await N(!0);let X=[];for(let j=0;j<s$1;j++)X.push(await N(j%2===0));let _e=X[X.length-1];if(_e===void 0)throw new Error(`Shader timing produced no runs for scene "${g.key}".`);if(E=_e,v=await x.observePublished(g,a$1),fr(v,g,"precompiled",n),bn(g,T,v),$=g.runtimeMotion?h(v.beforeScreenshot,v.screenshot,a$1.parity.channelTolerance,1):void 0,$&&$.diffRatio<1e-4)throw new Error(`Published scene "${g.key}" stopped animating during its normal 120-frame soak (changed ${$.differentPixels}/${$.totalPixels} canvas pixels).`);let ce=a(j=>j.stats.buildMs+(j.stats.precompiledSetupMs??0)+(j.stats.hydrationMs??0),"observedNodeBuilderMs"),fe=yn(X.map(j=>ce(j.live))),De=yn(X.map(j=>ce(j.precompiled))),le=Math.max(0,fe-De),He=X.map(j=>Math.max(0,ce(j.live)-ce(j.precompiled)));w[g.key]={builds:T.render+T.compute,setupMeasured:!0,liveBuildMs:fe,precompiledBuildMs:De,avoidedBuildMs:le,runs:s$1,spreadMs:Math.max(...He.map(j=>Math.abs(j-le)))};}let{diff:L,...D}=E.parity,{firstFrameScreenshot:re,screenshot:oe,...se}=E.live,{firstFrameScreenshot:be,screenshot:Pr,...mt}=E.precompiled,Ye;if(v!==void 0){let{beforeScreenshot:X,firstFrameScreenshot:_e,screenshot:ce,...fe}=v;Ye=fe;}R.push({scene:g.key,coverage:T,live:se,precompiled:mt,...Ye===void 0?{}:{published:Ye},parity:D,...$===void 0?{}:{runtimeMotion:{differentPixels:$.differentPixels,totalPixels:$.totalPixels,diffRatio:$.diffRatio}}}),await K(t$1,[g.key],i);}if(e.parityOnly===!0){if(await aa(t$1,[...C],i),A.length>0)throw new Error(`Shader parity failed for ${A.length}/${a$1.scenes.length} scene(s):
13
13
  `+A.map(S=>{let g=S.error instanceof Error?S.error.message:String(S.error);return ` - ${S.scene}: ${g}`}).join(`
14
14
  `));return {schemaVersion:1,root:t$1,noGpu:o$1,browser:"passed",scenes:R}}if(e.commitTiming===!0){let S={adapter:"WebGPU adapter",platform:`${Mt.platform()}/${Mt.arch()}`},g=await(b.timingEnvironment?.()??S),O=await M$1(t$1,w,g);return {schemaVersion:1,root:t$1,noGpu:o$1,browser:"passed",scenes:R,timing:O.local,committedTiming:O.committed}}let K$1=await J(t$1,w);return {schemaVersion:1,root:t$1,noGpu:o$1,browser:"passed",scenes:R,timing:K$1}}finally{u&&(await x.close(),await b.close());}}a(ua,"testShaders");function ma(e=process.env,t=process.stdout){if(e.NO_COLOR!==void 0)return 0;if(e.FORCE_COLOR!==void 0){let r=String(e.FORCE_COLOR);return r==="0"||r==="false"?0:r==="3"?24:r==="2"?8:4}return !t||!t.isTTY||e.TERM==="dumb"?0:/^(truecolor|24bit)$/i.test(e.COLORTERM??"")||e.WT_SESSION||e.TERM_PROGRAM==="iTerm.app"||e.TERM_PROGRAM==="vscode"?24:/-256(color)?$/i.test(e.TERM??"")?8:4}a(ma,"resolveColorDepth");function fa(e=process.env,t=process.platform){return t!=="win32"?true:!!(e.WT_SESSION||e.TERM_PROGRAM||e.ConEmuANSI||/-256(color)?$/i.test(e.TERM??""))}a(fa,"resolveUnicode");function pa(e=process.stdout){let t=e?.columns;return typeof t=="number"&&Number.isInteger(t)&&t>0?t:80}a(pa,"termWidth");var Sn={depth:ma(),unicode:fa(),fancy:!!process.stdout.isTTY&&process.env.TERM!=="dumb"},Ke={logo:{square:[30,84,200]},accent:[86,132,230],gold:[244,174,12],danger:[221,76,51],live:[212,255,71]};function ha(e,t,r){if(Math.max(e,t,r)-Math.min(e,t,r)<12){let o=Math.round((e+t+r)/3);return o<8?16:o>238?231:232+Math.round((o-8)/10)}let n=a(o=>o<48?0:o<115?1:Math.min(5,Math.round((o-35)/40)),"level");return 16+36*n(e)+6*n(t)+n(r)}a(ha,"ansi256");function qe(e,t,r){return r>=24?`38;2;${e[0]};${e[1]};${e[2]}`:r>=8?`38;5;${ha(e[0],e[1],e[2])}`:String(t)}a(qe,"fgOpen");function ya(e=Sn.depth,t=Sn.unicode){let r=e>0?(n,o=39)=>s=>`\x1B[${n}m${String(s)}\x1B[${o}m`:()=>n=>String(n);return {depth:e,unicode:t,accent:r(qe(Ke.accent,94,e)),live:r(qe(Ke.live,92,e)),danger:r(qe(Ke.danger,91,e)),gold:r(qe(Ke.gold,33,e)),deep:r(qe(Ke.logo.square,34,e)),warn:r(qe(Ke.gold,33,e)),dim:r(2,22),bold:r(1,22)}}a(ya,"createTheme");function ga(e){let t=e.unicode;return {tick:e.live(t?"\u2713":"\u221A"),cross:e.danger(t?"\u2717":"x"),warn:e.warn(t?"\u25B2":"!"),info:e.accent(t?"\u203A":">"),pointer:e.accent(t?"\u276F":">"),dot:e.dim(t?"\xB7":"."),ring:e.dim(t?"\u25CB":"o"),bar:t?"\u2502":"|",ellipsis:t?"\u2026":"...",mark:t?`${e.gold("\u25B2")} ${e.danger("\u25CF")} ${e.deep("\u25A0")}`:null,spin:t?["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]:["-","\\","|","/"]}}a(ga,"createSymbols");var _=ya(),F=ga(_),wa=/\x1b\[[0-9;]*m/g;function ba(e){return String(e).replace(wa,"")}a(ba,"stripAnsi");function Sa(e){return e===8203||e===8205||e>=768&&e<=879||e>=65024&&e<=65039?0:e>=4352&&e<=4447||e>=11904&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=129791||e>=131072&&e<=262141?2:1}a(Sa,"charWidth");function ka(e){let t=0;for(let r of ba(e))t+=Sa(r.codePointAt(0)??0);return t}a(ka,"visibleWidth");function yr(e,t){let r=t-ka(String(e));return r>0?String(e)+" ".repeat(r):String(e)}a(yr,"padEndAnsi");function Oe(e){return ["fresh","ready","precompiled","passed","captured","verified","first frame","compiled","worker ready","assets ready"].includes(e)?F.tick:["stale","live","generating","fallback","updating","skipped"].includes(e)?F.warn:["missing","starting","not-observed","unobserved"].includes(e)?F.ring:F.cross}a(Oe,"stateMark");var Ot=".three-blocks/runtime/status.json",lt=256*1024,Ft="three-blocks browser smoke",xa=["three-blocks.json","three-blocks.shaders.json","three-blocks.text.ts"];function Tn(e){return "kind"in e&&e.kind==="adopted"}a(Tn,"isAdoptedProjectStatus");async function It(e,t,r,n){let o=await l(e,t,r,n);return JSON.parse(o.data.toString("utf8"))}a(It,"readJsonWithin");var Ra=["starting","worker ready","assets ready","compiled","first frame","updating","error"],va=["ready","generating","fallback","missing","invalid"],Ea=["WebGPU","WebGL"],Ta=["OffscreenCanvas","MainThread"],Ba=/^[0-9A-Za-z][0-9A-Za-z._-]{0,63}$/,xn=16,Rn=1e9;function ie(e,t,r,n=[]){if(!a$1(e))throw new Error(`${t} must be an object.`);let o=new Set([...r,...n]);for(let s of r)if(!Object.hasOwn(e,s))throw new Error(`${t}.${s} is required.`);for(let s of Object.keys(e))if(!o.has(s))throw new Error(`${t}.${s} is not supported by schema v1.`);return e}a(ie,"exactRecord");function ct(e,t,r){if(typeof e!="string"||!t.includes(e))throw new Error(`${r} has an unsupported value.`);return e}a(ct,"enumValue");function ee(e,t){if(typeof e!="boolean")throw new Error(`${t} must be a boolean.`);return e}a(ee,"booleanValue");function vn(e,t){return e===null?null:ee(e,t)}a(vn,"nullableBoolean");function Ie(e,t){if(typeof e!="number"||!Number.isSafeInteger(e)||e<0||e>Rn)throw new Error(`${t} must be a non-negative integer no greater than ${Rn}.`);return e}a(Ie,"boundedCounter");function Pa(e){if(typeof e!="string"||e.length>32)throw new Error("Runtime status receipt observedAt must be a bounded ISO timestamp.");let t=Date.parse(e);if(!Number.isFinite(t)||new Date(t).toISOString()!==e)throw new Error("Runtime status receipt observedAt must be an exact ISO timestamp.");return e}a(Pa,"observedTimestamp");function $a(e){if(e===null)return null;if(typeof e!="string"||e.length===0||e.length>2048||/[\u0000-\u001f\u007f]/u.test(e))throw new Error("Runtime status receipt error must be null or one bounded display-safe line.");return e}a($a,"receiptError");function _a(e){if(!Array.isArray(e)||e.length>xn)throw new Error(`Runtime status receipt assets.codecs must contain at most ${xn} entries.`);let t=e.map((r,n)=>{let o=ie(r,`Runtime status receipt assets.codecs[${n}]`,["name","available","decoded"]);if(typeof o.name!="string"||!Ba.test(o.name))throw new Error(`Runtime status receipt assets.codecs[${n}].name is invalid.`);let s=ee(o.available,`Runtime status receipt assets.codecs[${n}].available`),a=ee(o.decoded,`Runtime status receipt assets.codecs[${n}].decoded`);if(a&&!s)throw new Error(`Runtime status receipt codec ${JSON.stringify(o.name)} cannot be decoded when unavailable.`);return {name:o.name,available:s,decoded:a}});if(new Set(t.map(r=>r.name)).size!==t.length)throw new Error("Runtime status receipt assets.codecs must have unique names.");return t}a(_a,"parseRuntimeCodecs");function Aa(e){if(e.assetsReady&&!e.workerReady)throw new Error("Runtime lifecycle assetsReady requires workerReady.");if(e.compiled&&!e.assetsReady)throw new Error("Runtime lifecycle compiled requires assetsReady.");if(e.firstFrame&&!e.compiled)throw new Error("Runtime lifecycle firstFrame requires compiled.");let t=e.state==="starting"?[false,false,false,false]:e.state==="worker ready"?[true,false,false,false]:e.state==="assets ready"?[true,true,false,false]:e.state==="compiled"?[true,true,true,false]:e.state==="first frame"||e.state==="updating"?[true,true,true,true]:null;if(t!==null&&![e.workerReady,e.assetsReady,e.compiled,e.firstFrame].every((r,n)=>r===t[n]))throw new Error(`Runtime lifecycle flags do not match state ${JSON.stringify(e.state)}.`)}a(Aa,"validateLifecycle");function Bn(e){let t=ie(e,"Runtime status receipt",["schemaVersion","observedAt","worker","assets","hmr","stats","lifecycle","shaders","error"],["text"]);if(t.schemaVersion!==1)throw new Error("Runtime status receipt must use schemaVersion 1.");let r=ie(t.worker,"Runtime status receipt worker",["backend","renderer","protocolVersion"]);if(r.protocolVersion!==1)throw new Error("Runtime status receipt worker.protocolVersion must be 1.");let n=ie(t.assets,"Runtime status receipt assets",["codecs","resources"]),o=ie(t.hmr,"Runtime status receipt hmr",["capabilities","outcome"]),s=ie(o.capabilities,"Runtime status receipt hmr.capabilities",["scene","component","assetManifest","workerRestart"]),a=ie(o.outcome,"Runtime status receipt hmr.outcome",["attempted","succeeded","rollbackPreserved","workerRestarted"]),i=ee(a.attempted,"Runtime status receipt hmr.outcome.attempted"),c=vn(a.succeeded,"Runtime status receipt hmr.outcome.succeeded"),u=vn(a.rollbackPreserved,"Runtime status receipt hmr.outcome.rollbackPreserved"),p=ee(a.workerRestarted,"Runtime status receipt hmr.outcome.workerRestarted");if(i?c===null||u===null:c!==null||u!==null||p)throw new Error("Runtime status receipt HMR outcome fields are inconsistent with attempted.");let l={scene:ee(s.scene,"Runtime status receipt hmr.capabilities.scene"),component:ee(s.component,"Runtime status receipt hmr.capabilities.component"),assetManifest:ee(s.assetManifest,"Runtime status receipt hmr.capabilities.assetManifest"),workerRestart:ee(s.workerRestart,"Runtime status receipt hmr.capabilities.workerRestart")};if(i&&!l.scene)throw new Error("Runtime status receipt cannot attempt HMR without the scene capability.");if(p&&!l.workerRestart)throw new Error("Runtime status receipt cannot restart a worker without the workerRestart capability.");let m=ie(t.stats,"Runtime status receipt stats",["snapshots","textures","workerProfiler","mainPanels"]),f=ie(t.lifecycle,"Runtime status receipt lifecycle",["state","workerReady","assetsReady","compiled","firstFrame"]),h={state:ct(f.state,Ra,"Runtime status receipt lifecycle.state"),workerReady:ee(f.workerReady,"Runtime status receipt lifecycle.workerReady"),assetsReady:ee(f.assetsReady,"Runtime status receipt lifecycle.assetsReady"),compiled:ee(f.compiled,"Runtime status receipt lifecycle.compiled"),firstFrame:ee(f.firstFrame,"Runtime status receipt lifecycle.firstFrame")};Aa(h);let y=ie(t.shaders,"Runtime status receipt shaders",["mode","pipelines"]),b=ct(y.mode,["precompiled","live"],"Runtime status receipt shaders.mode"),x=Ie(y.pipelines,"Runtime status receipt shaders.pipelines");if(b==="precompiled"&&x===0)throw new Error("A precompiled runtime receipt must observe at least one shader pipeline.");let R;if(t.text!==void 0){let A=ie(t.text,"Runtime status receipt text",["state","atlases","glyphs","requiredGlyphs"]);if(R={state:ct(A.state,va,"Runtime status receipt text.state"),atlases:Ie(A.atlases,"Runtime status receipt text.atlases"),glyphs:Ie(A.glyphs,"Runtime status receipt text.glyphs"),requiredGlyphs:Ie(A.requiredGlyphs,"Runtime status receipt text.requiredGlyphs")},R.state==="ready"&&(R.atlases===0||R.requiredGlyphs===0||R.glyphs<R.requiredGlyphs))throw new Error("A ready text receipt must cover a non-empty required glyph set with at least one atlas.")}let w=$a(t.error);if(h.state==="error"?w===null:w!==null)throw new Error("Runtime status receipt error must be present only when lifecycle.state is error.");return {schemaVersion:1,observedAt:Pa(t.observedAt),worker:{backend:ct(r.backend,Ta,"Runtime status receipt worker.backend"),renderer:ct(r.renderer,Ea,"Runtime status receipt worker.renderer"),protocolVersion:1},assets:{codecs:_a(n.codecs),resources:Ie(n.resources,"Runtime status receipt assets.resources")},hmr:{capabilities:l,outcome:{attempted:i,succeeded:c,rollbackPreserved:u,workerRestarted:p}},stats:{snapshots:Ie(m.snapshots,"Runtime status receipt stats.snapshots"),textures:Ie(m.textures,"Runtime status receipt stats.textures"),workerProfiler:ee(m.workerProfiler,"Runtime status receipt stats.workerProfiler"),mainPanels:ee(m.mainPanels,"Runtime status receipt stats.mainPanels")},lifecycle:h,shaders:{mode:b,pipelines:x},...R===void 0?{}:{text:R},error:w}}a(Bn,"parseRuntimeStatusReceipt");function Ca(e,t){return e.render===t.render&&e.vertex===t.vertex&&e.fragment===t.fragment&&e.compute===t.compute}a(Ca,"sameCoverage");async function gr(e=process.cwd()){let t=z.resolve(e);for(;;){if((await Promise.all(xa.map(n=>g(z.join(t,n))))).some(Boolean))return realpath(t);let r=z.dirname(t);if(r===t)return realpath(z.resolve(e));t=r;}}a(gr,"findProjectRoot");async function Ma(e,t){let r=t.template,n=z.join(e,".three-blocks","shaders"),o=z.join(n,"meta.json");if(!await g(n)||!await g(o))return {state:"missing",scene:r,reason:t.artifacts?.shaders==="pending"?"The selected template has no verified shader capture yet.":".three-blocks/shaders/meta.json is absent."};try{let s=await k(e,n,"Shader artifact directory"),a=c$1(await It(s,o,d$1.receipt,"Shader receipt")),i=a.scenes[r];if(i===void 0)return {state:"invalid",scene:r,reason:`Shader receipt has no "${r}" scene.`};let c=await l(s,z.join(s,i.artifact),d$1.manifest,"Shader manifest");if(f(c.data)!==i.artifactHash)return {state:"invalid",scene:r,reason:"The selected shader manifest checksum does not match its receipt."};let u=Et(c.data.toString("utf8"),c.path,r);if(!Ca(u,i.coverage))return {state:"invalid",scene:r,reason:"Shader receipt coverage does not match the manifest entries.",coverage:u};let{three:p,threeBlocks:l$1,threeBlocksShaderClosure:m}=await we(e);if(a.runtime.three!==p||t.runtime.three!==p||a.runtime.threeBlocks!==l$1||t.runtime.threeBlocks!==l$1)return {state:"stale",scene:r,reason:`Installed runtime versions (${p}, ${l$1}) do not match the metadata and shader receipt.`,coverage:u};if(a.runtime.threeBlocksShaderClosure!==m)return {state:"stale",scene:r,reason:"The installed three-blocks/shaders runtime closure differs from the capture receipt.",coverage:u};let f$1=await Te(e),h=Object.keys(f$1),y=Object.keys(i.inputs),b=h.filter(w=>!Object.hasOwn(i.inputs,w)),x=y.filter(w=>!Object.hasOwn(f$1,w)),R=h.filter(w=>Object.hasOwn(i.inputs,w)&&i.inputs[w]!==f$1[w]);return b.length>0||x.length>0||R.length>0?{state:"stale",scene:r,reason:`${b.length} added, ${x.length} removed, and ${R.length} changed semantic shader inputs.`,coverage:u,...R.length>0?{changedInputs:R}:{},...b.length>0?{addedInputs:b}:{},...x.length>0?{removedInputs:x}:{}}:{state:"fresh",scene:r,reason:"Manifest, installed shader runtime closure, and the shader-relevant source snapshot match.",coverage:u}}catch(s){return {state:"invalid",scene:r,reason:s instanceof Error?s.message:String(s)}}}a(Ma,"inspectShaders");async function Fa(e,t){if(t.artifacts?.text==="pending")return {state:"missing",reason:"The template has no verified text artifacts yet.",atlases:[]};let r=await Ct(e);return {state:r.state,reason:r.reason,atlases:r.atlases.map(n=>({name:n.font.key,glyphs:n.codePoints.length,width:n.texture.width,height:n.texture.height}))}}a(Fa,"inspectText");function Oa(e,t){if(e.lifecycle.assetsReady&&e.assets.codecs.some(r=>!r.available))throw new Error("Runtime status receipt claims assets ready while a configured codec is unavailable.");if(t.features.text!==(e.text!==void 0))throw new Error("Runtime status receipt text observation does not match three-blocks.json.")}a(Oa,"validateRuntimeReceiptForProject");async function Ia(e,t){let r=z.join(e,...Ot.split("/"));if(!await g(r))return {kind:"absent",receipt:null,reason:"No browser observation receipt is available."};try{let n=await k(e,z.dirname(r),"Runtime status receipt directory"),o=Bn(await It(n,z.join(n,z.basename(r)),lt,"Runtime status receipt"));return Oa(o,t),{kind:"valid",receipt:o,reason:o.error??`Browser observation captured at ${o.observedAt}.`}}catch(n){return {kind:"invalid",receipt:null,reason:`Runtime status receipt is invalid: ${n instanceof Error?n.message:String(n)}`}}}a(Ia,"inspectRuntimeReceipt");function La(){return {scene:false,component:false,assetManifest:false,workerRestart:false}}a(La,"emptyCapabilities");function ja(){return {attempted:false,succeeded:null,rollbackPreserved:null,workerRestarted:false}}a(ja,"emptyOutcome");function Na(){return []}a(Na,"configuredCodecs");function Da(e,t,r){if(t.state!=="fresh")return "three-blocks shaders capture";if(r!==void 0&&r.state!=="ready")return "three-blocks text generate";let n=e.receipt;return e.kind!=="valid"||n===null||n.lifecycle.state==="error"?Ft:n.text!==void 0&&n.text.state!=="ready"?"three-blocks text generate":Ft}a(Da,"recoveryCommand");async function Pn(e=process.cwd()){let t=await gr(e),r=b(await It(t,z.join(t,"three-blocks.json"),d$1.metadata,"Project metadata")),n=await Ma(t,r),o=r.features.text?await Fa(t,r):void 0,s=await Ia(t,r),a=s.receipt,i=s.kind==="invalid",c=i||a?.lifecycle.state==="error",u=a===null?{state:i?"error":"starting",backend:null,renderer:null,protocolVersion:1}:{state:c?"error":a.lifecycle.workerReady?"worker ready":"starting",backend:a.worker.backend,renderer:a.worker.renderer,protocolVersion:a.worker.protocolVersion},p=a===null?{state:i?"error":"starting",codecs:Na(),resources:0}:{state:c?"error":a.lifecycle.assetsReady?"assets ready":"starting",codecs:a.assets.codecs,resources:a.assets.resources},l=a===null?{state:i?"error":"starting",capabilities:La(),outcome:ja()}:{state:c||a.hmr.outcome.attempted&&(a.hmr.outcome.succeeded!==true||a.hmr.outcome.rollbackPreserved!==true)?"error":a.hmr.outcome.attempted?"first frame":"starting",capabilities:a.hmr.capabilities,outcome:a.hmr.outcome},m=a===null?{state:i?"error":"starting",snapshots:0,textures:0,workerProfiler:false,mainPanels:false}:{state:c?"error":a.stats.snapshots>0&&a.stats.workerProfiler&&a.stats.mainPanels?"first frame":"starting",...a.stats},f=a===null?{state:i?"error":"starting",mode:null,pipelines:0,artifactState:n.state}:{state:c?"error":a.lifecycle.compiled?n.state==="fresh"?a.shaders.mode:n.state:a.lifecycle.state,mode:a.shaders.mode,pipelines:a.shaders.pipelines,artifactState:n.state},h=o===void 0?void 0:a?.text===void 0?{state:i?"error":"starting",atlases:0,glyphs:0,requiredGlyphs:0}:{state:c?"error":o.state==="ready"?a.text.state:o.state,atlases:a.text.atlases,glyphs:a.text.glyphs,requiredGlyphs:a.text.requiredGlyphs};return {schemaVersion:1,root:t,metadata:r,configuration:{worker:u,assets:p,hmr:l,optimization:f,stats:m,...h===void 0?{}:{text:h}},runtime:{state:i?"error":a?.lifecycle.state??"starting",observed:a!==null,observedAt:a?.observedAt??null,reason:s.reason,recovery:Da(s,n,o),observation:a},shaders:n,...o?{text:o}:{}}}a(Pn,"inspectProject");async function En(e){let[t,r]=await Promise.all([g(z.join(e,"three-blocks.shaders.json")),g(z.join(e,"three-blocks.text.ts"))]),[n,o]=await Promise.all([t?Fe(e):Promise.resolve(void 0),r?Ct(e):Promise.resolve(void 0)]);return {schemaVersion:1,root:e,kind:"adopted",markers:{shaders:t,text:r},...n===void 0?{}:{shaders:n},...o===void 0?{}:{text:o}}}a(En,"inspectAdoptedProject");async function Ha(e=process.cwd()){let t=await gr(e),r=z.join(t,"three-blocks.json");if(await g(r)){try{b(await It(t,r,d$1.metadata,"Project metadata"));}catch{return En(t)}return Pn(t)}return En(t)}a(Ha,"inspectThreeBlocksStatus");function Va(e){return Tn(e)?(e.markers.shaders||e.markers.text)&&(e.shaders===void 0||e.shaders.state==="fresh")&&(e.text===void 0||e.text.state==="ready"):e.shaders.state==="fresh"&&(e.text===void 0||e.text.state==="ready")&&e.runtime.state!=="error"}a(Va,"threeBlocksStatusIsFresh");function Ua(e){return e==="ktx2"?"KTX2":e==="draco"?"Draco":e==="meshopt"?"Meshopt":e}a(Ua,"codecName");function Wa(e,t=Date.now()){let r=t-Date.parse(e);if(!Number.isFinite(r)||r<0)return e;let n=Math.round(r/1e3);if(n<60)return "just now";let o=Math.round(n/60);if(o<60)return `${o} minute${o===1?"":"s"} ago`;let s=Math.round(o/60);return s<48?`${s} hour${s===1?"":"s"} ago`:`${Math.round(s/24)} days ago`}a(Wa,"relativeTime");function ue(e,t,r){return `${e} ${yr(t,12)} ${r}`}a(ue,"row");function Be(e,t){return ` ${yr(_.dim(e),12)} ${_.dim(t)}`}a(Be,"subRow");function Ga(e){return e<100?e.toFixed(1):Math.round(e).toString()}a(Ga,"milliseconds");function za(e){return e?`${e.render} render \xB7 ${e.compute} compute`:"no coverage"}a(za,"coverageText");function $n(e){let t=[ue(Oe(e.state),"shaders",`${e.state==="fresh"?"fresh":_.warn(e.state)} ${F.dot} ${_.dim(e.reason)}`)];for(let r of e.scenes){let n=r.timing,o=n?.source==="committed-capture"?n.adapter??"captured adapter":"this capture",s=n===void 0?"":n.runs>1?`measured median of ${n.runs}`:"single-capture estimate",a=n===void 0?"":`\u2248${Ga(n.avoidedBuildMs)} ms TSL work avoided`,i=n===void 0?r.state==="fresh"?` ${F.dot} ${_.dim("capture again to record a timing estimate")}`:"":` ${F.dot} ${_.dim(`${a} \xB7 ${s} \xB7 ${o}`)}`;t.push(ue(Oe(r.state),r.scene,`${r.state} ${F.dot} ${za(r.coverage)}${i}`)),n!==void 0&&n.spreadMs>n.avoidedBuildMs*.4&&t.push(Be("measure",_.warn("noisy measurement \u2014 close other GPU apps and re-run")));let c=[...r.changedInputs??[],...r.addedInputs??[],...r.removedInputs??[]];c.length>0&&t.push(Be("changed",c.join(", ")));}return e.state!=="fresh"&&t.push(`${F.info} ${_.accent("three-blocks shaders capture")}`),t.join(`
15
15
  `)}a($n,"formatShaderMatrixStatus");function Ka(e){let t=e.scene,r=e.coverage,n=r?`${r.render} render \xB7 ${r.compute} compute`:"no coverage";if(e.state==="fresh")return [ue(Oe("fresh"),t,`fresh ${F.dot} ${n} ${F.dot} ${_.dim("precompiled at runtime")}`)];let o=[ue(Oe(e.state),t,`${e.state==="missing"?_.dim("missing"):_.warn(e.state)} ${F.dot} ${_.dim(e.reason)}`)],s=[...e.changedInputs??[],...e.addedInputs??[],...e.removedInputs??[]];return s.length>0&&o.push(Be("changed",s.join(", "))),o}a(Ka,"shaderRow");function _n(e,t=Date.now()){let r=F.mark?`${F.mark} `:"",n=e.metadata.runtime,o=[`${r}${_.bold("three-blocks")} ${_.dim("status")}`,Be("project",e.root),"",_.bold("Project"),ue(F.tick,e.metadata.template,`three ${n.three} ${F.dot} three-blocks ${n.threeBlocks}`),"",_.bold("Shaders"),...Ka(e.shaders)];if(e.text){let i=e.text,c=i.atlases.reduce((u,p)=>u+p.glyphs,0);o.push("",_.bold("Text"),ue(Oe(i.state),"coverage",i.state==="ready"?`ready ${F.dot} ${c} glyphs ${F.dot} ${i.atlases.length} atlas${i.atlases.length===1?"":"es"}`:`${_.warn(i.state)} ${F.dot} ${_.dim(i.reason)}`),...i.atlases.map(u=>Be("atlas",`${u.name} \xB7 ${u.glyphs} glyphs \xB7 ${u.width}\xD7${u.height}`)));}let s=e.runtime.observation;if(o.push("",_.bold("Browser check")),s!==null&&e.runtime.state!=="error"){let i=s.assets.codecs.map(c=>`${Ua(c.name)}${c.decoded?"":c.available?" (idle)":" (unavailable)"}`).join(" \xB7 ");o.push(ue(F.tick,"verified",`${Wa(s.observedAt,t)} ${F.dot} ${s.worker.renderer} worker ${F.dot} ${s.lifecycle.state} ${F.dot} ${s.shaders.pipelines} pipeline${s.shaders.pipelines===1?"":"s"} ${s.shaders.mode}`),Be("codecs",i||"none configured")),s.hmr.outcome.attempted&&o.push(Be("hmr",s.hmr.outcome.succeeded?`update succeeded${s.hmr.outcome.workerRestarted?" \xB7 worker restarted":""}`:"update failed"));}else e.runtime.state==="error"?o.push(ue(F.cross,"runtime",_.danger(e.runtime.reason))):o.push(ue(F.ring,"unverified",_.dim(`no browser run recorded \u2014 ${Ft}`)));return e.shaders.state==="fresh"&&(e.text===void 0||e.text.state==="ready")&&e.runtime.state!=="error"||o.push("",_.bold("Next"),`${F.info} ${_.accent(e.runtime.recovery)}`),o.join(`
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export{n as canReuseShaderBrowserSession,r as createAttachedPlaywrightShaderDriver,p as createPlaywrightShaderDriver,q as createStaticPlaywrightShaderDriver,o as isRetryableShaderObservationNavigation,m as publicBridgeScript,l as settleShaderParityFrames,k as waitForShaderCaptureAcrossNavigation}from'./chunk-QMP2MC4S.js';import'./chunk-NE7SC2BX.js';import'./chunk-ZT6T2W4B.js';import'./chunk-NEWSG5RX.js';import'./chunk-ZDNZCQUQ.js';import'./chunk-5L2VS3BN.js';import'./chunk-HOZDD6PW.js';
2
+ export{n as canReuseShaderBrowserSession,r as createAttachedPlaywrightShaderDriver,p as createPlaywrightShaderDriver,q as createStaticPlaywrightShaderDriver,o as isRetryableShaderObservationNavigation,m as publicBridgeScript,l as settleShaderParityFrames,k as waitForShaderCaptureAcrossNavigation}from'./chunk-HLYATKSG.js';import'./chunk-NE7SC2BX.js';import'./chunk-ZT6T2W4B.js';import'./chunk-NEWSG5RX.js';import'./chunk-ZDNZCQUQ.js';import'./chunk-5L2VS3BN.js';import'./chunk-HOZDD6PW.js';
@@ -1 +1 @@
1
- export{h as canReuseShaderBrowserSession,l as createAttachedPlaywrightShaderDriver,j as createPlaywrightShaderDriver,k as createStaticPlaywrightShaderDriver,i as isRetryableShaderObservationNavigation,g as publicBridgeScript,f as settleShaderParityFrames,e as waitForShaderCaptureAcrossNavigation}from'./chunk-LZX5NCGL.js';import'./chunk-RQEPJ6GC.js';import'./chunk-EI7MMDWY.js';
1
+ export{h as canReuseShaderBrowserSession,l as createAttachedPlaywrightShaderDriver,j as createPlaywrightShaderDriver,k as createStaticPlaywrightShaderDriver,i as isRetryableShaderObservationNavigation,g as publicBridgeScript,f as settleShaderParityFrames,e as waitForShaderCaptureAcrossNavigation}from'./chunk-E6JYGHBW.js';import'./chunk-RQEPJ6GC.js';import'./chunk-EI7MMDWY.js';