@three-blocks/devtools 11.0.0 → 11.1.0-alpha.395.g9b8ccb48a515
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/NOTICE +26 -0
- package/README.md +117 -170
- package/dist/asset-optimize-YJGWKD4Y.js +1 -0
- package/dist/asset-transforms-ZVZ4RD4L.js +11 -0
- package/dist/browser/shader-capture.js +2 -2
- package/dist/browser-smoke-4MYMHKWB.js +1 -0
- package/dist/chunk-4SVF5BRM.js +2 -0
- package/dist/chunk-7X4DHW36.js +1 -0
- package/dist/chunk-BBODS5RH.js +5 -0
- package/dist/{chunk-IILE5RBI.js → chunk-CMMYXGQ3.js} +1 -2
- package/dist/chunk-DCLDEPPB.js +253 -0
- package/dist/{chunk-5L2VS3BN.js → chunk-ECQE4D2U.js} +1 -2
- package/dist/chunk-IWQV456Z.js +3 -0
- package/dist/chunk-LSH64HEU.js +80 -0
- package/dist/{chunk-X5OFYHIY.js → chunk-MIJXPQPM.js} +2 -3
- package/dist/chunk-NDIPQLTU.js +16 -0
- package/dist/{chunk-NPLE7PPF.js → chunk-NJITVI23.js} +1 -2
- package/dist/chunk-O5FU2ASS.js +16 -0
- package/dist/chunk-QQKHDH26.js +1 -0
- package/dist/chunk-S5LI2C2H.js +5 -0
- package/dist/chunk-SBUKHO24.js +1 -0
- package/dist/chunk-TK566QET.js +1 -0
- package/dist/{chunk-65VEJRRT.js → chunk-WNSGAV6N.js} +1 -2
- package/dist/chunk-ZG3LO3VB.js +1 -0
- package/dist/{chunk-UDUICSME.js → chunk-ZTHZE36A.js} +1 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +26 -26
- package/dist/environment-bake-ON5I27N7.js +1 -0
- package/dist/index.d.ts +24 -12
- package/dist/index.js +1 -279
- package/dist/{shader-autowire-SPE5DM2X.js → shader-autowire-D2EOG6GF.js} +1 -2
- package/dist/shader-browser-6ICBHK3S.js +1 -0
- package/dist/shader-capture-server.d.ts +1 -1
- package/dist/shader-capture-server.js +1 -1
- package/dist/{shader-config-EOFU5D3Y.js → shader-config-AKZEKIRB.js} +1 -2
- package/dist/{shader-parity-QXJWR6OZ.js → shader-parity-7DEPQEDI.js} +1 -1
- package/dist/{shader-project-runner-S2AID2RJ.js → shader-project-runner-NV4GKHDX.js} +1 -2
- package/dist/shader-watch-JBUA4LP5.js +1 -0
- package/dist/shader-workflow-5EHHR32D.js +1 -0
- package/dist/status-GDVSLQWV.js +1 -0
- package/dist/text-atlas-YYWV7S6F.js +1 -0
- package/dist/transform.cjs +1 -1
- package/dist/transform.js +1 -1
- package/dist/webpack-loader.cjs +1 -1
- package/dist/webpack-loader.js +1 -1
- package/node/index.d.mts +70 -0
- package/node/index.mjs +407 -0
- package/node/ipc.mjs +31 -0
- package/node/layout.mjs +546 -0
- package/node/loader.mjs +103 -0
- package/node/media.mjs +454 -0
- package/node/recording.mjs +67 -0
- package/node/worker.mjs +1314 -0
- package/package.json +27 -11
- package/dist/asset-optimize-GG72JCOX.js +0 -6
- package/dist/browser-smoke-KFF7XV7F.js +0 -254
- package/dist/chunk-45AVKQQK.js +0 -80
- package/dist/chunk-5FT6AZD6.js +0 -82
- package/dist/chunk-7N6TU4JG.js +0 -17
- package/dist/chunk-EI7MMDWY.js +0 -1
- package/dist/chunk-HOZDD6PW.js +0 -2
- package/dist/chunk-LKXY5YU2.js +0 -17
- package/dist/chunk-MIUIIPS4.js +0 -1
- package/dist/chunk-NF4RFSUJ.js +0 -18
- package/dist/chunk-QJFPNM6W.js +0 -2
- package/dist/chunk-ZT6T2W4B.js +0 -2
- package/dist/chunk-ZZLAZ7GJ.js +0 -6
- package/dist/environment-bake-BGMGFAVK.js +0 -4
- package/dist/shader-browser-H5CB2ZQX.js +0 -2
- package/dist/shader-browser-UXXR6QI2.js +0 -1
- package/dist/shader-parity-XPKQQK26.js +0 -2
- package/dist/shader-watch-EORZ2SEC.js +0 -2
- package/dist/shader-workflow-7NQFDQI5.js +0 -2
- package/dist/status-PTBB4SW2.js +0 -2
- package/dist/text-atlas-UORTLOQJ.js +0 -2
- /package/dist/{chunk-TRHSN2DJ.cjs → chunk-LMLJIVNY.cjs} +0 -0
package/dist/chunk-45AVKQQK.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import {d,a as a$1,X,z,Y,B,U,m,l,h,g,S}from'./chunk-NF4RFSUJ.js';import {a}from'./chunk-EI7MMDWY.js';import x from'process';import {createServer}from'http';import {createRequire}from'module';import {mkdtemp,rm,lstat,realpath}from'fs/promises';import A from'path';import {tmpdir}from'os';import {pathToFileURL}from'url';var Le=Object.freeze([{id:"three-inspector-invalid-json",pattern:/is not valid JSON/iu},{id:"chromium-webgpu-experimental",pattern:/WebGPU is experimental/iu},{id:"browser-automatic-favicon",pattern:/Failed to load resource:.*404.*\/favicon\.ico/iu}]);function Z(n){return Le.some(e=>e.pattern.test(n))}a(Z,"isDocumentedBrowserNoise");function fe(n=x.env,e=x.platform){let t=n.THREE_BLOCKS_WEBGPU_BROWSER_ARGS?.split(/\s+/u).filter(Boolean);if(t&&t.length>0)return t;let r=["--enable-unsafe-webgpu"];return e==="darwin"&&r.push("--enable-gpu","--use-angle=metal"),e==="linux"&&r.push("--enable-features=Vulkan","--disable-vulkan-surface","--ignore-gpu-blocklist","--disable-gpu-driver-bug-workarounds","--disable-gpu-watchdog"),r}a(fe,"webgpuBrowserArgs");function pe(n=x.env){let e=n.THREE_BLOCKS_WEBGL_BROWSER_ARGS?.split(/\s+/u).filter(Boolean);return e&&e.length>0?e:["--use-angle=swiftshader","--enable-unsafe-swiftshader","--ignore-gpu-blocklist"]}a(pe,"webglBrowserArgs");function we(n=false,e=x.env){return n!==true&&e.THREE_BLOCKS_SOFTWARE_WEBGPU!=="1"}a(we,"webgpuBrowserHeadless");var ee="three-blocks.shader-capture.runtime.v1";var Re="/__three-blocks/shaders/capture",K="/__three-blocks/shaders/telemetry",Te="/__three-blocks/shaders/runtime.js",ke="/__three-blocks/shaders/bootstrap.js",Ee="/__three-blocks/shaders/bridge.js",Pe=d.manifest*2,ne=/^[a-z0-9][a-z0-9_-]{0,63}$/u,Ce=64,Be=3e4;async function Ve(){try{return (await import('playwright')).chromium}catch(n){throw new Error('Shader browser work requires the optional "playwright" package. Install it in the project and run `npx playwright install chromium`.',{cause:n})}}a(Ve,"loadChromium");async function We(n){let e;try{e=createRequire(A.join(n,"package.json")).resolve("vite");}catch(r){throw new Error("Shader capture requires Vite in the target project.",{cause:r})}let t=await import(pathToFileURL(e).href);if(typeof t.createServer!="function")throw new Error(`The target project's Vite entry does not export createServer(): ${e}`);return t.createServer}a(We,"loadProjectCreateServer");var ae=class{static{a(this,"CaptureInbox");}#e=new Map;#t=new Map;wait(e,t){let r=this.#t.get(e);if(r!==void 0)return this.#t.delete(e),Promise.resolve(r);if(this.#e.has(e))throw new Error(`A shader capture is already waiting for scene "${e}".`);return new Promise((a,s)=>{let o=setTimeout(()=>{this.#e.delete(e),s(new Error(`Shader capture "${e}" timed out after ${t}ms.`));},t);this.#e.set(e,{resolve:a,reject:s,timer:o});})}receive(e){if(!a$1(e)||typeof e.scene!="string"||!ne.test(e.scene))throw new Error("Capture POST has no safe scene key.");if(!this.#t.has(e.scene)&&!this.#e.has(e.scene)&&this.#t.size>=Ce)throw new Error("Capture POST exceeds the scene inbox limit.");let t=this.#e.get(e.scene);t?(clearTimeout(t.timer),this.#e.delete(e.scene),t.resolve(e)):this.#t.set(e.scene,e);}cancel(e,t){let r=this.#e.get(e);r&&(clearTimeout(r.timer),this.#e.delete(e),r.reject(t));}rejectAll(e){for(let t of this.#e.values())clearTimeout(t.timer),t.reject(e);this.#e.clear(),this.#t.clear();}};async function Je(n,e){let t=await Promise.race([e.then(r=>({kind:"capture",value:r})),n.then(()=>({kind:"navigation"}))]);return t.kind==="capture"?t.value:e}a(Je,"waitForShaderCaptureAcrossNavigation");var oe=class{static{a(this,"TelemetryHub");}#e=new Map;#t=new Map;markFirstRequest(e){ne.test(e)&&!this.#t.has(e)&&this.#t.set(e,Date.now());}firstRequest(e){return this.#t.get(e)}receive(e){if(!a$1(e)||typeof e.scene!="string"||!ne.test(e.scene))throw new Error("Shader telemetry has no bounded scene key.");if(!this.#e.has(e.scene)&&this.#e.size>=Ce)throw new Error("Shader telemetry exceeds the scene limit.");this.#e.set(e.scene,e);}read(e){return this.#e.get(e)}clear(e){this.#e.delete(e),this.#t.delete(e);}},Ke=a(async(n,e,t,r,a)=>{let s=0;for(;n.__threeBlocksParityUsesAnimationLoop!==true&&s<e;)await r(),s+=1;if(n.__threeBlocksParityUsesAnimationLoop===true){let o=Number(n.__threeBlocksParityCompletedFrame||0),i=Number(t),d=Number.isSafeInteger(i)&&i>=o?i:o+e;for(n.__threeBlocksParityTargetFrame=d;Number(n.__threeBlocksParityCompletedFrame||0)<d;)await r();}return await a(),Number(n.__threeBlocksParityCompletedFrame||0)},"settleShaderParityFrames");function se(n,e){return `(() => {
|
|
2
|
-
const root = globalThis;
|
|
3
|
-
const scene = new URL(location.href).searchParams.get('captureId')
|
|
4
|
-
|| 'default';
|
|
5
|
-
const workerCapture = ${JSON.stringify(e??null).replaceAll("<","\\u003c")};
|
|
6
|
-
if (workerCapture) root[Symbol.for('three-blocks.shader-capture.worker-activation.v1')] = { ...workerCapture, scene };
|
|
7
|
-
const randomSeed = (value) => {
|
|
8
|
-
let state = 2166136261;
|
|
9
|
-
for (let index = 0; index < value.length; index++) state = Math.imul(state ^ value.charCodeAt(index), 16777619) >>> 0;
|
|
10
|
-
return state === 0 ? 0x9e3779b9 : state;
|
|
11
|
-
};
|
|
12
|
-
const advanceRandom = (state) => {
|
|
13
|
-
state ^= state << 13;
|
|
14
|
-
state ^= state >>> 17;
|
|
15
|
-
state ^= state << 5;
|
|
16
|
-
return state >>> 0;
|
|
17
|
-
};
|
|
18
|
-
const parityMode = new URL(location.href).searchParams.get('threeBlocksShaderMode');
|
|
19
|
-
if (parityMode === 'live' || parityMode === 'precompiled') {
|
|
20
|
-
root.__threeBlocksParityEpoch = 1700000000000;
|
|
21
|
-
root.__threeBlocksParityTime = 0;
|
|
22
|
-
Date.now = () => root.__threeBlocksParityEpoch + Number(root.__threeBlocksParityTime || 0);
|
|
23
|
-
}
|
|
24
|
-
const randomStreams = new Map();
|
|
25
|
-
Math.random = () => {
|
|
26
|
-
const stackLine = String(new Error().stack || '').split('\\n')[2] || 'unknown';
|
|
27
|
-
const originIndex = stackLine.indexOf(location.origin);
|
|
28
|
-
const callsite = (originIndex >= 0 ? stackLine.slice(0, originIndex) : stackLine).trim() || 'anonymous';
|
|
29
|
-
const next = advanceRandom(randomStreams.get(callsite) ?? randomSeed(scene + '|' + callsite));
|
|
30
|
-
randomStreams.set(callsite, next);
|
|
31
|
-
return next / 4294967296;
|
|
32
|
-
};
|
|
33
|
-
const readiness = { workerReady: false, assetsReady: false, textReady: false, compileEnd: false, firstFrame: false };
|
|
34
|
-
const stats = { buildCalls: 0, renderBuilds: 0, computeBuilds: 0, registeredBuilds: 0, registeredRenderBuilds: 0, registeredComputeBuilds: 0, buildMs: 0, syncBuildMs: 0, asyncBuildElapsedMs: 0, precompiledSetupMs: 0, maxSyncBuildMs: 0, maxPrecompiledSetupMs: 0, hydrationMs: 0, maxHydrationMs: 0, injected: 0, injectedRender: 0, injectedCompute: 0, missed: 0, missedRender: 0, missedCompute: 0, missedKeys: [] };
|
|
35
|
-
const settleParityFrames = ${Ke.toString()};
|
|
36
|
-
const settle = (frames, requestedTarget) => settleParityFrames(
|
|
37
|
-
root,
|
|
38
|
-
frames,
|
|
39
|
-
requestedTarget,
|
|
40
|
-
() => new Promise((resolve) => requestAnimationFrame(resolve)),
|
|
41
|
-
() => new Promise((resolve) => setTimeout(resolve, 100)),
|
|
42
|
-
);
|
|
43
|
-
const bridge = { protocolVersion: 1, compatibility: ${JSON.stringify(n)}, transform: ${B}, readiness, stats, settle };
|
|
44
|
-
root.__threeBlocksShaderTools = bridge;
|
|
45
|
-
requestAnimationFrame(() => requestAnimationFrame(() => { readiness.firstFrame = true; }));
|
|
46
|
-
const poll = async () => {
|
|
47
|
-
try {
|
|
48
|
-
const response = await fetch('/__three-blocks/shaders/telemetry?scene=' + encodeURIComponent(scene), { cache: 'no-store' });
|
|
49
|
-
if (response.status !== 204 && response.ok) {
|
|
50
|
-
const payload = await response.json();
|
|
51
|
-
if (payload.protocolVersion !== 1 || payload.compatibility !== bridge.compatibility || payload.transform !== bridge.transform) throw new Error('incompatible shader telemetry');
|
|
52
|
-
Object.assign(stats, payload.stats);
|
|
53
|
-
if (Array.isArray(payload.demands)) bridge.demands = payload.demands;
|
|
54
|
-
if (typeof payload.demandTotal === 'number') bridge.demandTotal = payload.demandTotal;
|
|
55
|
-
readiness.workerReady = true;
|
|
56
|
-
if (payload.settled === true) {
|
|
57
|
-
readiness.assetsReady = true;
|
|
58
|
-
readiness.textReady = true;
|
|
59
|
-
readiness.compileEnd = true;
|
|
60
|
-
}
|
|
61
|
-
const smoke = root.__threeBlocksSmoke && typeof root.__threeBlocksSmoke === 'object' ? root.__threeBlocksSmoke : { protocolVersion: 1, worker: { offscreenCanvas: true, visible: true }, readiness: {} };
|
|
62
|
-
smoke.readiness = { ...(smoke.readiness || {}), ...readiness };
|
|
63
|
-
root.__threeBlocksSmoke = smoke;
|
|
64
|
-
}
|
|
65
|
-
} catch {}
|
|
66
|
-
setTimeout(poll, 40);
|
|
67
|
-
};
|
|
68
|
-
void poll();
|
|
69
|
-
})();`}a(se,"publicBridgeScript");function _e(n,e,t,r,a=false){let s=new URL(n.url??"/","http://three-blocks.invalid"),o=s.pathname;if(a&&n.method==="GET"&&/^\/three-blocks\/shaders\/[a-z0-9][a-z0-9_-]{0,63}\.(?:webgpu|webgl)\.json$/u.test(o))return e.statusCode=204,e.end(),true;if(o===K&&n.method==="GET"){let h=s.searchParams.get("scene")??"",S=r.read(h);return S===void 0?(e.statusCode=204,e.end()):(e.statusCode=200,e.setHeader("Content-Type","application/json"),e.end(JSON.stringify(S))),true}let i=o===Re,d=o===K;if(!i&&!d)return false;if(n.method!=="POST")return e.statusCode=405,e.end("POST required"),true;let u=[],f=0,p=false;return n.on("data",h=>{f+=h.byteLength,f>Pe?p=true:u.push(h);}),n.on("end",()=>{if(p){e.statusCode=413,e.end("capture payload too large");return}try{let h=JSON.parse(Buffer.concat(u).toString("utf8"));d?r.receive(h):t.receive(h),e.statusCode=204,e.end();}catch(h){e.statusCode=400,e.end(h instanceof Error?h.message:String(h));}}),true}a(_e,"handleCaptureEndpoint");function qe(n,e,t,r,a){return {name:"three-blocks:shader-capture-endpoint",transformIndexHtml(){return [{tag:"script",children:se(r,a),injectTo:"head-prepend"}]},configureServer(s){s.middlewares.use((o,i,d)=>{let f=new URL(o.url??"/","http://three-blocks.invalid").searchParams.get("captureId");f!==null&&e.markFirstRequest(f),!_e(o,i,n,e,t)&&d();});}}}a(qe,"captureEndpointPlugin");function ge(n,e,t){let r=new URL(e.url,n);for(let[a,s]of Object.entries(t))r.searchParams.set(a,s);return r.href}a(ge,"browserUrl");function ze(n,e,t){let r=new URL(e.url,n);for(let a of ["capture","precompiled"])r.searchParams.delete(a);return r.searchParams.set("captureId",e.key),r.searchParams.set("threeBlocksShaderCapture","1"),r.searchParams.set("threeBlocksShaderMode","precompiled"),t==="webgl"&&r.searchParams.set("webgl","1"),r.searchParams.set("tbStats","1"),r.href}a(ze,"publishedBrowserUrl");async function M(n){let e;try{await Promise.race([n(),new Promise(t=>{e=setTimeout(t,Be);})]);}catch{}finally{e&&clearTimeout(e);}}a(M,"closeBrowserResource");async function J(n){let e;try{return await Promise.race([n().catch(()=>null),new Promise(t=>{e=setTimeout(()=>t(null),Be);})])}finally{e!==void 0&&clearTimeout(e);}}a(J,"readPageDiagnostic");function te(n){let e=a(()=>{},"resolveFirst"),t=new Promise(u=>{e=u;}),r=a(()=>{},"removeBrowserListener"),a$1={console:[],page:[],first:t,dispose:a(()=>r(),"dispose")},s=false,o=a(u=>{s||(s=true,e(new Error(u)));},"report"),i=n.context().browser(),d=a(()=>o("Shader browser disconnected before observation completed."),"onDisconnected");return i?.on("disconnected",d),r=a(()=>{i?.off("disconnected",d);},"removeBrowserListener"),n.on("console",u=>{let f=u.type()==="warning"&&/\[three-blocks\/shaders\].*(?:has no entry|manifest miss|hydration)/iu.test(u.text());if(u.type()!=="error"&&!f||Z(u.text()))return;let p=u.location().url,h=p.length>0?`${u.text()} (${p})`:u.text();a$1.console.push(h),o(`Browser console ${f?"warning":"error"}: ${h}`);}),n.on("pageerror",u=>{if(Z(u.message))return;let f=u.stack||u.message;a$1.page.push(f),o(`Browser page error: ${f}`);}),n.on("crash",()=>o("Browser page crashed before shader capture completed.")),n.on("close",()=>o("Browser page closed before shader capture completed.")),a$1}a(te,"collectErrors");function L(n,e,t=false){return typeof n[e]=="boolean"?n[e]:t}a(L,"booleanField");function Ye(n){if(!a$1(n))throw new Error("Browser shader stats are unavailable.");let e=a((t,r=true)=>{let a=n[t];if(typeof a!="number"||!Number.isFinite(a)||a<0||r&&!Number.isSafeInteger(a))throw new Error(`Browser shader stats.${t} is invalid.`);return a},"read");return {buildCalls:e("buildCalls"),renderBuilds:e("renderBuilds"),computeBuilds:e("computeBuilds"),registeredBuilds:e("registeredBuilds"),registeredRenderBuilds:e("registeredRenderBuilds"),registeredComputeBuilds:e("registeredComputeBuilds"),buildMs:e("buildMs",false),syncBuildMs:e("syncBuildMs",false),asyncBuildElapsedMs:e("asyncBuildElapsedMs",false),precompiledSetupMs:e("precompiledSetupMs",false),maxSyncBuildMs:e("maxSyncBuildMs",false),maxPrecompiledSetupMs:e("maxPrecompiledSetupMs",false),hydrationMs:e("hydrationMs",false),maxHydrationMs:e("maxHydrationMs",false),injected:e("injected"),injectedRender:e("injectedRender"),injectedCompute:e("injectedCompute"),missed:e("missed"),missedRender:e("missedRender"),missedCompute:e("missedCompute"),...Array.isArray(n.missedKeys)&&n.missedKeys.every(t=>typeof t=="string")?{missedKeys:n.missedKeys}:{}}}a(Ye,"parseStats");function V(n,e,t,r,a){if(!a$1(n))throw new Error("The page did not expose the public shader devtools bridge.");if(!t&&n.protocolVersion!==1)throw new Error(`Scene "${e.key}" exposed an unsupported shader bridge protocol.`);let s=n.readiness;if(!a$1(s))throw new Error("The shader bridge readiness snapshot is invalid.");let o={workerReady:L(s,"workerReady"),assetsReady:L(s,"assetsReady"),textReady:e.requiresText?L(s,"textReady"):true,compileEnd:L(s,"compileEnd"),firstFrame:L(s,"firstFrame",t)};if(!o.workerReady||!o.assetsReady||!o.textReady||!o.compileEnd)throw new Error(`Scene "${e.key}" did not reach worker/assets/text/compile readiness.`);let i=t?a:n.compatibility,d=t?B:n.transform;if(i!==a||d!==B)throw new Error(`Scene "${e.key}" exposed incompatible shader bridge metadata.`);Y(r);let u=Array.isArray(n.demands)?n.demands.filter(a$1).slice(0,64):void 0;return {compatibility:a,transform:d,readiness:o,stats:Ye(n.stats),...u===void 0?{}:{demands:u}}}a(V,"parseBridge");async function W(n,e){return n.evaluate(t=>{let r=globalThis;if(!t)return r.__threeBlocksShaderTools??null;let a=r.__threeBlocks,s=r.__threeBlocksTslStats;if(!a||typeof a!="object")return null;let o=a;return {readiness:{workerReady:o.workerReady===true,assetsReady:o.loadEnd===true||o.assetsReady===true,textReady:o.textReady===true,compileEnd:o.compileEnd===true,firstFrame:true},stats:s}},e)}a(W,"readBridge");async function xe(n,e){let t=await J(()=>n.evaluate(r=>{let a$1=globalThis,s=a(i=>{let d=a$1;for(let u of i.split(".")){if(d===null||typeof d!="object"&&typeof d!="function")return;d=Reflect.get(d,u);}return d},"resolveGlobal"),o=null;if(r!==null)try{o=JSON.stringify(s(`${r}Diagnostics`))??null;}catch{o=null;}return JSON.stringify({parityCompletedFrame:Number(a$1.__threeBlocksParityCompletedFrame??0),diagnostics:o})},e??null));return t===null?{alive:false,signature:""}:{alive:true,signature:t}}a(xe,"probePageProgress");async function F(n,e,t,r){let a$1=n.evaluate(async u=>{let p=globalThis.__threeBlocksShaderTools;if(p&&typeof p=="object"){let g=Reflect.get(p,"settle");if(typeof g=="function"){let c=await g(u.frames,u.targetFrame);return typeof c=="number"&&Number.isSafeInteger(c)?c:0}}if(!u.legacy||!u.modulePath)throw new Error("The public shader bridge does not provide deterministic settle().");let h=await import(u.modulePath);if(!h.store||typeof h.store!="object")throw new Error("Legacy deterministic store is unavailable.");let S=h.store;return S.recordFrameCount=0,S.recordFrameRate=60,S.recordTotalFrames=u.frames,S.recording=true,await new Promise((g,c)=>{let w=Date.now(),m=a(()=>{if(S.recording===false)return g();if(Date.now()-w>u.timeoutMs)return c(new Error("Legacy deterministic settle timed out."));setTimeout(m,25);},"poll");m();}),0},{frames:t,targetFrame:r,legacy:e.bridge.legacyLab,modulePath:e.bridge.deterministicModule??null,timeoutMs:e.timeoutMs}),s=j(e),o=false,i,d=(async()=>{let u=Date.now(),f=u,p="";for(;;){let h=s-(Date.now()-u);if(h<=0)throw new Error(`Shader parity settle timed out after ${s}ms.`);let S=e.timeoutMs-(Date.now()-f);if(S<=0){let g=await xe(n,e.readiness.global);if(o)throw new Error("Shader parity settle already resolved.");if(g.alive&&g.signature===p)throw new Error(`Shader parity settle timed out after ${e.timeoutMs}ms without progress (hard cap ${s}ms).`);p=g.signature,f=Date.now();continue}if(await new Promise(g=>{i=setTimeout(g,Math.min(S,h,2500));}),o)throw new Error("Shader parity settle already resolved.")}})();try{return await Promise.race([a$1,d])}finally{o=true,i!==void 0&&clearTimeout(i),d.catch(()=>{});}}a(F,"settlePage");async function Se(n,e,t){e.readiness.selector===void 0&&e.readiness.global===void 0||await Promise.race([n.waitForFunction(r=>{let a=globalThis;if(r.selector!==void 0&&a.document?.querySelector(r.selector)==null)return false;if(r.global===void 0)return true;let s=a;for(let d of r.global.split(".")){if((typeof s!="object"||s===null)&&typeof s!="function")return false;s=Reflect.get(s,d);}if(s===true)return true;if(typeof s!="object"||s===null||typeof Reflect.get(s,"then")!="function")return false;let o=a.__threeBlocksReadinessState,i=o instanceof Map?o:new Map;return o instanceof Map||(a.__threeBlocksReadinessState=i),i.has(s)||(i.set(s,false),Promise.resolve(s).then(()=>i.set(s,true),()=>i.set(s,false))),i.get(s)===true},e.readiness,{timeout:j(e)}),t.first.then(r=>Promise.reject(r))]);}a(Se,"waitForConfiguredReadiness");async function be(n){let e=n.locator("canvas"),r=(await e.evaluateAll(a=>a.map((s,o)=>{let i=s.getBoundingClientRect();return {index:o,area:Math.max(0,i.width)*Math.max(0,i.height)}}))).sort((a,s)=>s.area-a.area)[0];if(r===void 0||r.area<=0)throw new Error("Published page has no visible renderer canvas.");return Buffer.from(await e.nth(r.index).screenshot({type:"png"}))}a(be,"primaryCanvasScreenshot");async function re(n,e,t,r,a,s,o){let i=q(r,a,s),d=await U(),u=`(() => {
|
|
70
|
-
const runtime = globalThis[Symbol.for(${JSON.stringify(ee)})];
|
|
71
|
-
if (!runtime || typeof runtime.configureThreeBlocksShaderCapture !== 'function') {
|
|
72
|
-
throw new Error('@three-blocks/devtools attached shader capture runtime is incompatible.');
|
|
73
|
-
}
|
|
74
|
-
runtime.configureThreeBlocksShaderCapture(${JSON.stringify(i).replaceAll("<","\\u003c")});
|
|
75
|
-
})();`;await n.addInitScript({content:`${d}
|
|
76
|
-
${u}`}),await n.addInitScript({content:se(o,i)}),await n.route("**/*",async f=>{let p=f.request(),h=new URL(p.url()),S=h.pathname;if(p.method()==="GET"&&r!=="precompiled"&&/^\/three-blocks\/shaders\/[a-z0-9][a-z0-9_-]{0,63}\.(?:webgpu|webgl)\.json$/u.test(S)){await f.fulfill({status:204});return}if(S===K&&p.method()==="GET"){let w=t.read(h.searchParams.get("scene")??"");await f.fulfill(w===void 0?{status:204}:{status:200,contentType:"application/json",body:JSON.stringify(w)});return}let g=S===Re,c=S===K;if((g||c)&&p.method()==="POST"){let w=p.postDataBuffer()??Buffer.alloc(0);if(w.byteLength>Pe){await f.fulfill({status:413,body:"capture payload too large"});return}try{let m=JSON.parse(w.toString("utf8"));c?t.receive(m):e.receive(m),await f.fulfill({status:204});}catch(m){await f.fulfill({status:400,body:m instanceof Error?m.message:String(m)});}return}await f.continue();});}a(re,"configureAttachedContext");var Xe=Object.freeze({".avif":"image/avif",".css":"text/css; charset=utf-8",".gif":"image/gif",".html":"text/html; charset=utf-8",".ico":"image/x-icon",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"text/javascript; charset=utf-8",".json":"application/json; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".mp4":"video/mp4",".png":"image/png",".svg":"image/svg+xml",".wasm":"application/wasm",".webm":"video/webm",".webp":"image/webp",".woff":"font/woff",".woff2":"font/woff2"});function Qe(n){let e=[`<script src="${Ee}"></script>`,`<script type="module" src="${ke}"></script>`].join(""),t=/<head(?:\s[^>]*)?>/iu.exec(n);return t===null?`${e}${n}`:`${n.slice(0,t.index+t[0].length)}${e}${n.slice(t.index+t[0].length)}`}a(Qe,"injectStaticShaderCaptureHtml");function Ze(n,e,t){let r=q(n,e,t);return [`import { configureThreeBlocksShaderCapture } from ${JSON.stringify(Te)};`,`configureThreeBlocksShaderCapture( ${JSON.stringify(r).replaceAll("<","\\u003c")} );`].join(`
|
|
77
|
-
`)}a(Ze,"staticCaptureBootstrap");var et=5e3;function j(n){return Math.max(n.maxTimeoutMs??n.timeoutMs,n.timeoutMs)}a(j,"configuredHardCapMs");function q(n,e,t){return {capture:n==="capture",backend:t,driven:true,forceLive:n!=="precompiled",settleFrames:e.settleFrames,settleTimeoutMs:e.settleTimeoutMs??3e4,...n==="capture"?{deadlineAt:Date.now()+Math.max(1e3,j(e)-et)}:{},readiness:e.readiness,transform:B}}a(q,"shaderCaptureConfiguration");async function tt(n,e){let t=await m(n,e,o=>/\.(?:c|m)?js$/u.test(o),16384),r=false,a=false,s;for(let o of t){let i=(await l(n,o,d.texture,"Static application JavaScript")).data.toString("utf8");if(i.includes("nodeBuilderStateProvider")&&(r=true),i.includes("three-blocks.shader-capture.runtime.v1")&&(a=true,s??=o),r&&a)break}if(!r||!a)throw new Error("The static build does not contain the Three.js shader capture transform. Run `shaders capture` without an explicit driver or URL to preview adapter wiring and build automatically, or add the manual adapter from the package README and rebuild.");return {seen:true,applied:true,alreadyPresent:false,captureApplied:true,...s===void 0?{}:{id:s}}}a(tt,"inspectStaticCaptureTransform");async function rt(n,e){let t;try{t=decodeURIComponent(e);}catch{return}if(t.includes("\0"))return;let r=t.replace(/^\/+/u,""),a=A.resolve(n,r.length===0?"index.html":r);if(!h(n,a)||a===n||(await g(a)&&(await lstat(a)).isDirectory()&&(a=A.join(a,"index.html")),!await g(a)&&A.extname(a).length===0&&(a=A.join(n,"index.html")),!await g(a)))return;let s=await l(n,a,d.texture,"Static application asset");return {data:s.data,file:s.path}}a(rt,"staticRequestFile");async function nt(n,e,t,r,a,s){let o=await realpath(n.root),i=await realpath(A.resolve(o,n.serve));if(!h(o,i)||i===o)throw new Error("--serve must name a built application directory inside the project root.");let d=await tt(o,i),u=await S(),f=Ze(e,r,t),p=se(z(n.runtime.three,t),q(e,r,t)),h$1=createServer((g,c)=>{(async()=>{if(_e(g,c,a,s,e!=="precompiled"))return;let w=new URL(g.url??"/","http://three-blocks.invalid");if(g.method!=="GET"&&g.method!=="HEAD"){c.statusCode=405,c.end("GET or HEAD required");return}let m=w.pathname===Te?u:w.pathname===ke?f:w.pathname===Ee?p:void 0;if(m!==void 0){c.statusCode=200,c.setHeader("Content-Type","text/javascript; charset=utf-8"),c.setHeader("Cache-Control","no-store"),c.end(g.method==="HEAD"?void 0:m);return}let y=await rt(i,w.pathname);if(y===void 0){c.statusCode=404,c.end("Not found");return}let v=A.extname(y.file).toLowerCase(),b=v===".html"?Buffer.from(Qe(y.data.toString("utf8"))):y.data;c.statusCode=200,c.setHeader("Content-Type",Xe[v]??"application/octet-stream"),c.setHeader("Content-Length",String(b.byteLength)),c.setHeader("Cache-Control","no-store"),c.end(g.method==="HEAD"?void 0:b);})().catch(w=>{if(c.headersSent)return c.destroy(w instanceof Error?w:void 0);c.statusCode=500,c.end(w instanceof Error?w.message:String(w));});});await new Promise((g,c)=>{h$1.once("error",c),h$1.listen(0,"127.0.0.1",()=>{h$1.off("error",c),g();});});let S$1=h$1.address();if(!S$1||typeof S$1=="string")throw new Error("Static capture server did not expose an ephemeral TCP address.");return {server:h$1,baseUrl:`http://127.0.0.1:${S$1.port}`,transform:d}}a(nt,"startStaticShaderServer");function at(n,e,t){return n===e?true:t&&n!==void 0&&n!=="capture"&&e!=="capture"}a(at,"canReuseShaderBrowserSession");function ve(n){let e=n instanceof Error?n.message:String(n);return e.includes("Execution context was destroyed")&&e.includes("navigation")||/^launch: Timeout \d+ms exceeded\./u.test(e)||e.includes("Shader browser disconnected before observation completed.")}a(ve,"isRetryableShaderObservationNavigation");var $=class{static{a(this,"PlaywrightShaderDriver");}#e;#t=new ae;#n=new oe;#h;#m;#s;#i;#r;#a;#f;#l;#p;#w;#u=0;#c;constructor(e){this.#e=e;}#d(){return this.#h?.status??this.#m??{seen:false,applied:false,alreadyPresent:false}}async#y(e,t){if(this.#r?.isConnected()===true)return;this.#r=void 0;let r=await Ve();this.#c??=await mkdtemp(A.join(tmpdir(),"three-blocks-shader-cache-"));let a=r.launch({headless:t==="webgl"?this.#e.headed!==true:we(this.#e.headed===true),args:[...t==="webgl"?pe():fe(),`--disk-cache-dir=${this.#c}`],timeout:e.timeoutMs}),s;try{this.#r=await Promise.race([a,new Promise((o,i)=>{s=setTimeout(()=>i(new Error(`launch: Timeout ${e.timeoutMs}ms exceeded.`)),e.timeoutMs);})]);}catch(o){throw a.then(i=>M(()=>i.close()),()=>{}),o}finally{s!==void 0&&clearTimeout(s);}this.#u=0;}async#o(e,t,r){let a;try{return await Promise.race([r(),new Promise((s,o)=>{a=setTimeout(()=>o(new Error(`launch: Timeout ${t.timeoutMs}ms exceeded.`)),t.timeoutMs);})])}catch(s){throw this.#r===e&&(this.#r=void 0),await M(()=>e.close()),s}finally{a!==void 0&&clearTimeout(a);}}async#g(e,t,r){let a=this.#s!==void 0||this.#i!==void 0||this.#e.url!==void 0&&this.#a!==void 0,s=this.#p===t&&(this.#i!==void 0?this.#l===e:at(this.#l,e,r.bridge.legacyLab));if(a&&s){this.#l=e,await this.#y(r,t);return}if(a&&await this.close(),this.#l=e,this.#p=t,this.#e.url!==void 0){let o=new URL(this.#e.url);if(!["http:","https:"].includes(o.protocol)||o.username||o.password||o.hash)throw new Error("Attached shader URL must be an HTTP(S) URL without credentials or a fragment.");this.#a=o.href,this.#m={seen:true,applied:true,alreadyPresent:false,captureApplied:true,id:"attached-application"},await this.#y(r,t);return}if(this.#e.serve!==void 0)try{let o=await nt({root:this.#e.root,runtime:this.#e.runtime,serve:this.#e.serve,...this.#e.headed===void 0?{}:{headed:this.#e.headed}},e,t,r,this.#t,this.#n);this.#i=o.server,this.#m=o.transform,this.#a=o.baseUrl,await this.#y(r,t);return}catch(o){throw await this.close(),o}this.#h=X(this.#e.runtime.three,{disableTimestampQueries:x.env.THREE_BLOCKS_SOFTWARE_WEBGPU==="1",...r.bridge.legacyLab?{}:{capture:{capture:e==="capture",driven:true,forceLive:e!=="precompiled",forceWebGL:t==="webgl",settleFrames:r.settleFrames,settleTimeoutMs:r.settleTimeoutMs??3e4,readiness:r.readiness}}}),this.#f={THREE_BLOCKS_SHADER_TOOL:x.env.THREE_BLOCKS_SHADER_TOOL,THREE_BLOCKS_PRECOMPILE_CAPTURE_SERVER:x.env.THREE_BLOCKS_PRECOMPILE_CAPTURE_SERVER},x.env.THREE_BLOCKS_SHADER_TOOL="1",x.env.THREE_BLOCKS_PRECOMPILE_CAPTURE_SERVER="1";try{let o=await We(this.#e.root);this.#s=await o({root:this.#e.root,logLevel:"error",plugins:[this.#h.plugin,qe(this.#t,this.#n,e!=="precompiled",z(this.#e.runtime.three,t),q(e,r,t))],server:{host:"127.0.0.1",port:0}}),await this.#s.listen();let i=this.#s.httpServer?.address();if(!i||typeof i=="string")throw new Error("Vite did not expose an ephemeral TCP address.");this.#a=`http://127.0.0.1:${i.port}`,await this.#y(r,t);}catch(o){throw await this.close(),o}}async capture(e,t,r="webgpu"){let a$2=Date.now();if(await this.#g("capture",r,t),!this.#r||!this.#a)throw new Error("Shader browser driver did not start.");let s=this.#r,o=await this.#o(s,t,()=>s.newContext({viewport:t.viewport}));this.#e.url!==void 0&&await this.#o(s,t,()=>re(o,this.#t,this.#n,"capture",t,r,z(this.#e.runtime.three,r)));let i=await this.#o(s,t,()=>o.newPage()),d=te(i);this.#n.clear(e.key);let u=j(t),f=this.#t.wait(e.key,u),p=false;u>t.timeoutMs?(async()=>{let m=Math.min(5e3,Math.max(1e3,Math.round(t.timeoutMs/8))),y=Date.now(),v="",b="";for(;!p;){if(await new Promise(k=>setTimeout(k,m)),p)return;let T=this.#n.read(e.key),B=T===void 0?"":JSON.stringify(T);if(B!==v){v=B,y=Date.now();continue}if(Date.now()-y<t.timeoutMs)continue;let E=await xe(i,t.readiness.global);if(p)return;if(!E.alive||E.signature!==b){b=E.signature,y=Date.now();continue}this.#t.cancel(e.key,new Error(`Shader capture "${e.key}" timed out after ${t.timeoutMs}ms without progress (hard cap ${u}ms).`));return}})().catch(()=>{}):void 0;let S=Promise.race([f,d.first.then(m=>Promise.reject(m))]),g=a(()=>{},"resolveDisconnected"),c=new Promise(m=>{g=m;}),w=a(()=>g(new Error("Shader capture browser disconnected before posting a manifest.")),"onDisconnected");s.on("disconnected",w);try{let m=i.goto(ge(this.#a,e,{threeBlocksShaderCapture:"1",capture:"1",captureId:e.key,captureFrames:String(Math.max(4,t.settleFrames)),settleFrames:String(t.settleFrames),...r==="webgl"?{webgl:"1"}:{}}),{waitUntil:"domcontentloaded",timeout:t.timeoutMs}),y=await Je(m,Promise.race([S,c.then(b=>Promise.reject(b))]));Y(this.#d());let v=[...d.page,...d.console];if(v.length>0)throw new Error(`Capture browser errors:
|
|
78
|
-
- ${v.join(`
|
|
79
|
-
- `)}`);return a$1(y)?{...y,timing:{...a$1(y.timing)?y.timing:{},launch:a$2,...this.#n.firstRequest(e.key)===void 0?{}:{firstRequest:this.#n.firstRequest(e.key)},posted:Date.now()}}:y}catch(m){let y=m instanceof Error?m:new Error(String(m));this.#t.cancel(e.key,y),await f.catch(()=>{});let v=this.#n.read(e.key);if(y.message.includes("timed out")){let b=await J(()=>i.evaluate(E=>{let k=globalThis,N=k.__threeBlocksShaderTools,Me=N&&typeof N=="object"?N:void 0,Oe=k.document,O=Reflect.get(k,Symbol.for("three-blocks.shader-capture.cache-value.v1")),I=k.location,Ae=I!==null&&typeof I=="object"&&typeof Reflect.get(I,"href")=="string"?String(Reflect.get(I,"href")):"http://three-blocks.invalid/",je=new URL(Ae).searchParams.get("captureId")??"default",ie=O!==null&&typeof O=="object"&&typeof Reflect.get(O,"registrations")=="function"?Reflect.apply(Reflect.get(O,"registrations"),O,[je]):void 0,de=a(R=>{let _=k;for(let De of R.split(".")){if(_===null||typeof _!="object"&&typeof _!="function")return;_=Reflect.get(_,De);}return _},"resolveGlobal"),le=null,z=null;if(E!==null){let R=de(E);le=R===true||R===false?R:R===void 0?"absent":R!==null&&typeof R.then=="function"?"promise":typeof R;try{let _=JSON.stringify(de(`${E}Diagnostics`));z=typeof _=="string"?_.slice(0,2048):null;}catch{z=null;}}return {documentReadyState:Oe?.readyState??null,parityTargetFrame:Number(k.__threeBlocksParityTargetFrame??0),parityCompletedFrame:Number(k.__threeBlocksParityCompletedFrame??0),readiness:Me?.readiness??null,readinessGlobal:le,readinessDiagnostics:z,captureCache:O!==null&&typeof O=="object"?{activeScene:Reflect.get(O,"activeScene")??null,registrations:Array.isArray(ie)?ie.slice(0,16).map(R=>R!==null&&typeof R=="object"?{key:Reflect.get(R,"key")??null,kind:Reflect.get(R,"kind")??null}:null):null}:null,threeRuntimeResources:performance.getEntriesByType("resource").map(R=>R.name).filter(R=>R.includes("three.webgpu"))}},t.readiness.global??null)),T=t.readiness.global!==void 0&&b!==null&&b.readinessGlobal!==true,B=b===null?"Capture page did not answer diagnostics before the deadline; its main thread was blocked or gone. ":T?`Application readiness "${t.readiness.global}" never completed (state: ${JSON.stringify(b.readinessGlobal)}${b.readinessDiagnostics===null?"":`, diagnostics: ${b.readinessDiagnostics}`}). `:"";throw new Error(`${B}${y.message} Last capture state for "${e.key}": ${JSON.stringify({page:b,telemetry:v??null,transform:this.#d()})}`)}throw y}finally{p=true,d.dispose(),s.off("disconnected",w),await M(()=>o.close()),this.#u++,(!s.isConnected()||this.#u>=(t.browserRelaunchScenes??8))&&(this.#r===s&&(this.#r=void 0),await M(()=>s.close()),this.#u=0);}}async observe(e,t,r,a,s="webgpu"){for(let o=0;o<2;o++)try{return await this.#S(e,s,t,r,a)}catch(i){if(o===0&&ve(i))continue;throw i}throw new Error(`Shader observation retry was exhausted for scene "${e.key}".`)}async#S(e,t,r,a,s){if(await this.#g(r,t,a),!this.#r||!this.#a)throw new Error("Shader browser driver did not start.");let o=this.#r,i=await this.#o(o,a,()=>o.newContext({viewport:a.viewport}));this.#e.url!==void 0&&await this.#o(o,a,()=>re(i,this.#t,this.#n,r,a,t,z(this.#e.runtime.three,t)));let d=await this.#o(o,a,()=>i.newPage()),u=te(d);this.#n.clear(e.key);try{await d.goto(ge(this.#a,e,{threeBlocksShaderCapture:"1",threeBlocksShaderMode:r,captureId:e.key,...r==="live"?{precompiled:"0"}:{},...t==="webgl"?{webgl:"1"}:{}}),{waitUntil:"domcontentloaded",timeout:a.timeoutMs}),await Promise.race([d.waitForFunction(a.bridge.legacyLab?"globalThis.__threeBlocks?.compileEnd === true":"globalThis.__threeBlocksShaderTools?.readiness?.compileEnd === true",void 0,{timeout:j(a)}),u.first.then(c=>Promise.reject(c))]),V(await W(d,a.bridge.legacyLab),e,a.bridge.legacyLab,this.#d(),z(this.#e.runtime.three,t)),await Se(d,a,u),await Promise.race([d.waitForFunction(a.bridge.legacyLab?"true":"globalThis.__threeBlocksShaderTools?.readiness?.firstFrame === true",void 0,{timeout:j(a)}),u.first.then(c=>Promise.reject(c))]),await F(d,a,1);let f=Buffer.from(await d.screenshot({type:"png",timeout:a.timeoutMs})),p=e.parityFrames??a.parity.frames,h=await F(d,a,p,s),S=Buffer.from(await d.screenshot({type:"png",timeout:a.timeoutMs}));e.parityFrames!==void 0&&p<a.parity.frames&&await F(d,a,a.parity.frames-p);let g=V(await W(d,a.bridge.legacyLab),e,a.bridge.legacyLab,this.#d(),z(this.#e.runtime.three,t));return this.#w===void 0&&(this.#w=await d.evaluate(async c=>{if(c==="webgl"){let E=Reflect.get(globalThis,"document").querySelector("canvas")?.getContext("webgl2"),k=E?.getExtension("WEBGL_debug_renderer_info");return {adapter:E&&k?String(E.getParameter(k.UNMASKED_RENDERER_WEBGL)):"WebGL adapter",platform:navigator.platform||navigator.userAgent}}let w=Reflect.get(navigator,"gpu"),m=typeof w=="object"&&w!==null?Reflect.get(w,"requestAdapter"):void 0,y=typeof m=="function"?await Reflect.apply(m,w,[]):void 0,v=typeof y=="object"&&y!==null?Reflect.get(y,"info"):void 0,b=["description","device","architecture","vendor"].flatMap(T=>{let B=typeof v=="object"&&v!==null?Reflect.get(v,T):void 0;return typeof B=="string"&&B.length>0?[B]:[]});return {adapter:[...new Set(b)].join(" \xB7 ")||"WebGPU adapter",platform:navigator.platform||navigator.userAgent}},t)),{scene:e.key,mode:r,...g,frame:h,firstFrameScreenshot:f,screenshot:S,errors:[...u.page,...u.console]}}catch(f){let p=f instanceof Error?f:new Error(String(f));if(/(?:timed?\s*out|timeout)/iu.test(p.message)){let c=this.#n.read(e.key),w=await J(()=>d.evaluate(()=>{let m=globalThis,y=m.__threeBlocksShaderTools,v=y&&typeof y=="object"?y:void 0;return {documentReadyState:m.document?.readyState??null,parityTargetFrame:Number(m.__threeBlocksParityTargetFrame??0),parityCompletedFrame:Number(m.__threeBlocksParityCompletedFrame??0),readiness:v?.readiness??null,threeRuntimeResources:performance.getEntriesByType("resource").map(T=>T.name).filter(T=>T.includes("three.webgpu"))}}));throw new Error(`${p.message} Last ${r} state for "${e.key}": ${JSON.stringify({page:w,telemetry:c??null})}`)}let h=this.#n.read(e.key),g=(a$1(h)&&Array.isArray(h.demands)&&h.demands.length>0?JSON.stringify(h.demands).slice(0,6e3):void 0)??await J(()=>d.evaluate(c=>{let w=globalThis,m=Reflect.get(w,Symbol.for(c)),y=m!==null&&typeof m=="object"?Reflect.get(m,"readThreeBlocksShaderDemands"):void 0,v=typeof y=="function"?Reflect.apply(y,m,[]):void 0,b=w.__threeBlocksShaderTools,T=Array.isArray(v)&&v.length>0?v:b&&typeof b=="object"?Reflect.get(b,"demands"):void 0;return Array.isArray(T)&&T.length>0?JSON.stringify(T).slice(0,6e3):null},ee));throw typeof g=="string"?new Error(`${p.message}
|
|
80
|
-
${r} demands: ${g}`):p}finally{u.dispose(),await M(()=>i.close());}}async observePublished(e,t,r="webgpu"){for(let a=0;a<2;a++)try{return await this.#b(e,r,t)}catch(s){if(a===0&&ve(s))continue;throw s}throw new Error(`Published shader observation retry was exhausted for scene "${e.key}".`)}async#b(e,t,r){if(await this.#g("precompiled",t,r),!this.#r||!this.#a)throw new Error("Shader browser driver did not start.");let a=this.#r,s=await this.#o(a,r,()=>a.newContext({viewport:r.viewport}));this.#e.url!==void 0&&await this.#o(a,r,()=>re(s,this.#t,this.#n,"precompiled",r,t,z(this.#e.runtime.three,t)));let o=await this.#o(a,r,()=>s.newPage()),i=te(o);this.#n.clear(e.key);try{await o.goto(ze(this.#a,e,t),{waitUntil:"domcontentloaded",timeout:r.timeoutMs}),await Promise.race([o.waitForFunction(r.bridge.legacyLab?"globalThis.__threeBlocks?.compileEnd === true":"globalThis.__threeBlocksShaderTools?.readiness?.compileEnd === true",void 0,{timeout:j(r)}),i.first.then(h=>Promise.reject(h))]),await Se(o,r,i),V(await W(o,r.bridge.legacyLab),e,r.bridge.legacyLab,this.#d(),z(this.#e.runtime.three,t)),await F(o,r,2);let d=await be(o),u=await F(o,r,120),f=await be(o),p=V(await W(o,r.bridge.legacyLab),e,r.bridge.legacyLab,this.#d(),z(this.#e.runtime.three,t));return {scene:e.key,mode:"precompiled",...p,frame:u,firstFrameScreenshot:d,beforeScreenshot:d,screenshot:f,errors:[...i.page,...i.console]}}finally{i.dispose(),await M(()=>s.close());}}timingEnvironment(){return this.#w??{adapter:this.#p==="webgl"?"WebGL adapter":"WebGPU adapter",platform:`${x.platform}/${x.arch}`}}async close(){this.#t.rejectAll(new Error("Shader browser driver closed.")),this.#r&&await M(()=>this.#r?.close()??Promise.resolve());let e=this.#s?.httpServer,t=e?Reflect.get(e,"closeAllConnections"):void 0;if(e&&typeof t=="function"&&Reflect.apply(t,e,[]),this.#s&&await M(()=>this.#s?.close()??Promise.resolve()),this.#i){let r=this.#i;r.closeAllConnections(),await M(()=>new Promise(a=>{r.close(()=>a());}));}if(this.#r=void 0,this.#s=void 0,this.#i=void 0,this.#a=void 0,this.#h=void 0,this.#m=void 0,this.#l=void 0,this.#p=void 0,this.#w=void 0,this.#u=0,this.#c!==void 0&&(await rm(this.#c,{recursive:true,force:true}),this.#c=void 0),this.#f){for(let[r,a]of Object.entries(this.#f))a===void 0?delete x.env[r]:x.env[r]=a;this.#f=void 0;}}};function Tt(n){return new $(n)}a(Tt,"createPlaywrightShaderDriver");function kt(n){return new $(n)}a(kt,"createStaticPlaywrightShaderDriver");function Et(n){return new $(n)}a(Et,"createAttachedPlaywrightShaderDriver");export{Le as a,Z as b,fe as c,we as d,Je as e,Ke as f,se as g,at as h,ve as i,Tt as j,kt as k,Et as l};
|
package/dist/chunk-5FT6AZD6.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {a as a$3,b as b$1}from'./chunk-7N6TU4JG.js';import {c,b,d,a as a$4}from'./chunk-QJFPNM6W.js';import {a as a$2}from'./chunk-65VEJRRT.js';import {a as a$1,j as j$1,k,e,d as d$1}from'./chunk-5L2VS3BN.js';import {a}from'./chunk-HOZDD6PW.js';import x from'process';import {createServer}from'http';import {createRequire}from'module';import {mkdtemp,rm,lstat,realpath}from'fs/promises';import O from'path';import {tmpdir}from'os';import {pathToFileURL}from'url';import {THREE_WEBGPU_R185_COMPATIBILITY}from'three-blocks/shaders';import {transformThreeWebgpuProviderHooks,transformThreeWebgpuCaptureInstrumentation}from'three-blocks/vite';var ee="three-blocks.shader-capture.runtime.v1";var $;async function I(){$===void 0&&($=(async()=>{let e=createRequire(O.join(process.cwd(),"package.json")).resolve("@three-blocks/devtools/browser/shader-capture"),r=O.resolve(O.dirname(e),"../..");return (await j$1(r,e,a$1.metadata,"Shader capture browser runtime")).data.toString("utf8")})());let t=$;try{return await t}catch(e){throw $===t&&($=void 0),e}}a(I,"loadShaderCaptureRuntimeSource");var we="virtual:three-blocks-shader-capture-client",ge="\0three-blocks:shader-capture-client",te="virtual:three-blocks-shader-capture-runtime",Se="\0three-blocks:shader-capture-runtime";async function ve(){let t=await I(),e=t.replace(/\bexport\{[^{}]*\};?\s*$/u,"");if(e===t)throw new Error("Shader capture browser runtime no longer has the expected final ESM export list.");return e}a(ve,"loadShaderCaptureRuntimeScriptSource");function Je(t){let e=t.split("?",1)[0];return e===void 0?false:e.split(O.sep).join("/").endsWith("/build/three.webgpu.js")}a(Je,"isThreeWebGPUModule");function Te(t){let e=/^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/u.exec(t);return e?.[1]==="0"&&e[2]==="185"}a(Te,"supportedVersion");function qe(t,e,r={}){if(!Te(e))throw new Error(`Shader provider transform ${THREE_WEBGPU_R185_COMPATIBILITY} supports Three.js 0.185.x; received "${e}".`);let n=transformThreeWebgpuProviderHooks(t,{threeVersion:e,...r.threeRevision===void 0?{}:{threeRevision:r.threeRevision},id:"three/build/three.webgpu.js"}),a=n.state==="already-applied",s=n.code;return r.instrumentCapture&&(s=transformThreeWebgpuCaptureInstrumentation(s,{...r.captureRuntimeImport===void 0?{}:{runtimeImport:r.captureRuntimeImport},...r.forceWebGL===true?{forceWebGL:true}:{}}).code),{code:s,alreadyPresent:a,captureApplied:r.instrumentCapture===true}}a(qe,"applyShaderProviderTransform");var ze=/this\.trackTimestamp\s*=\s*\(\s*parameters\.trackTimestamp\s*===\s*true\s*\);/gu,Ye="Object.defineProperty( this, 'trackTimestamp', { get: () => false, set: () => {} } );";function Re(t,e={}){if(!Te(t))throw new Error(`Shader provider transform ${THREE_WEBGPU_R185_COMPATIBILITY} supports Three.js 0.185.x; received "${t}".`);let r={seen:false,applied:false,alreadyPresent:false};return {plugin:{name:"three-blocks:shader-provider-transform",enforce:"pre",config(){return {optimizeDeps:{exclude:["three","three/webgpu","three/tsl"]},resolve:{dedupe:["three"]}}},resolveId(a){return e.capture&&a===we?ge:e.capture&&a===te?Se:null},async load(a){return e.capture?a===Se?I():a===ge?[`export * from '${te}';`,`import { configureThreeBlocksShaderCapture } from '${te}';`,`configureThreeBlocksShaderCapture( ${JSON.stringify({capture:e.capture.capture,backend:e.capture.forceWebGL===true?"webgl":"webgpu",forceLive:e.capture.forceLive,driven:e.capture.driven,settleFrames:e.capture.settleFrames,settleTimeoutMs:e.capture.settleTimeoutMs,visibilityGuard:e.capture.visibilityGuard,captureId:e.capture.captureId,sessionKey:e.capture.sessionKey,token:e.capture.token,readiness:e.capture.readiness??{},transform:b$1})} );`].join(`
|
|
3
|
-
`):null:null},transform(a,s){if(!Je(s))return null;r.seen=true,r.id=s;try{let o=qe(a,t,{instrumentCapture:e.capture!==void 0,forceWebGL:e.capture?.forceWebGL===!0,...e.capture!==void 0?{captureRuntimeImport:we}:{}}),i=e.disableTimestampQueries===!0?o.code.replace(ze,Ye):o.code;if(e.disableTimestampQueries===!0&&i===o.code)throw new Error("Three.js timestamp tracking anchor drifted; refusing software WebGPU capture.");return r.applied=!0,r.alreadyPresent=o.alreadyPresent,r.captureApplied=o.captureApplied,i===a?null:{code:i,map:null}}catch(o){throw r.error=o instanceof Error?o.message:String(o),o}}},status:r}}a(Re,"createShaderProviderTransform");function ne(t){if(t.error)throw new Error(t.error);if(!t.seen||!t.applied)throw new Error(`The version-gated shader provider transform was not applied (${t.seen?"module seen":"three/webgpu not seen"}).`)}a(ne,"assertShaderProviderTransform");var Be="/__three-blocks/shaders/capture",z="/__three-blocks/shaders/telemetry",xe="/__three-blocks/shaders/runtime.js",Me="/__three-blocks/shaders/bootstrap.js",Ae="/__three-blocks/shaders/bridge.js",Oe=a$1.manifest*2,se=/^[a-z0-9][a-z0-9_-]{0,63}$/u,De=64,je=3e4;async function ar(){try{return (await import('playwright')).chromium}catch(t){throw new Error('Shader browser work requires the optional "playwright" package. Install it in the project and run `npx playwright install chromium`.',{cause:t})}}a(ar,"loadChromium");async function or(t){let e;try{e=createRequire(O.join(t,"package.json")).resolve("vite");}catch(n){throw new Error("Shader capture requires Vite in the target project.",{cause:n})}let r=await import(pathToFileURL(e).href);if(typeof r.createServer!="function")throw new Error(`The target project's Vite entry does not export createServer(): ${e}`);return r.createServer}a(or,"loadProjectCreateServer");var ie=class{static{a(this,"CaptureInbox");}#e=new Map;#r=new Map;wait(e,r){let n=this.#r.get(e);if(n!==void 0)return this.#r.delete(e),Promise.resolve(n);if(this.#e.has(e))throw new Error(`A shader capture is already waiting for scene "${e}".`);return new Promise((a,s)=>{let o=setTimeout(()=>{this.#e.delete(e),s(new Error(`Shader capture "${e}" timed out after ${r}ms.`));},r);this.#e.set(e,{resolve:a,reject:s,timer:o});})}receive(e){if(!a$2(e)||typeof e.scene!="string"||!se.test(e.scene))throw new Error("Capture POST has no safe scene key.");if(!this.#r.has(e.scene)&&!this.#e.has(e.scene)&&this.#r.size>=De)throw new Error("Capture POST exceeds the scene inbox limit.");let r=this.#e.get(e.scene);r?(clearTimeout(r.timer),this.#e.delete(e.scene),r.resolve(e)):this.#r.set(e.scene,e);}cancel(e,r){let n=this.#e.get(e);n&&(clearTimeout(n.timer),this.#e.delete(e),n.reject(r));}rejectAll(e){for(let r of this.#e.values())clearTimeout(r.timer),r.reject(e);this.#e.clear(),this.#r.clear();}};async function sr(t,e){let r=await Promise.race([e.then(n=>({kind:"capture",value:n})),t.then(()=>({kind:"navigation"}))]);return r.kind==="capture"?r.value:e}a(sr,"waitForShaderCaptureAcrossNavigation");var de=class{static{a(this,"TelemetryHub");}#e=new Map;#r=new Map;markFirstRequest(e){se.test(e)&&!this.#r.has(e)&&this.#r.set(e,Date.now());}firstRequest(e){return this.#r.get(e)}receive(e){if(!a$2(e)||typeof e.scene!="string"||!se.test(e.scene))throw new Error("Shader telemetry has no bounded scene key.");if(!this.#e.has(e.scene)&&this.#e.size>=De)throw new Error("Shader telemetry exceeds the scene limit.");this.#e.set(e.scene,e);}read(e){return this.#e.get(e)}clear(e){this.#e.delete(e),this.#r.delete(e);}},ir=a(async(t,e,r,n,a)=>{let s=0;for(;t.__threeBlocksParityUsesAnimationLoop!==true&&s<e;)await n(),s+=1;if(t.__threeBlocksParityUsesAnimationLoop===true){let o=Number(t.__threeBlocksParityCompletedFrame||0),i=Number(r),l=Number.isSafeInteger(i)&&i>=o?i:o+e;for(t.__threeBlocksParityTargetFrame=l;Number(t.__threeBlocksParityCompletedFrame||0)<l;)await n();}return await a(),Number(t.__threeBlocksParityCompletedFrame||0)},"settleShaderParityFrames");function le(t,e){return `(() => {
|
|
4
|
-
const root = globalThis;
|
|
5
|
-
const scene = new URL(location.href).searchParams.get('captureId')
|
|
6
|
-
|| 'default';
|
|
7
|
-
const workerCapture = ${JSON.stringify(e??null).replaceAll("<","\\u003c")};
|
|
8
|
-
if (workerCapture) root[Symbol.for('three-blocks.shader-capture.worker-activation.v1')] = { ...workerCapture, scene };
|
|
9
|
-
const randomSeed = (value) => {
|
|
10
|
-
let state = 2166136261;
|
|
11
|
-
for (let index = 0; index < value.length; index++) state = Math.imul(state ^ value.charCodeAt(index), 16777619) >>> 0;
|
|
12
|
-
return state === 0 ? 0x9e3779b9 : state;
|
|
13
|
-
};
|
|
14
|
-
const advanceRandom = (state) => {
|
|
15
|
-
state ^= state << 13;
|
|
16
|
-
state ^= state >>> 17;
|
|
17
|
-
state ^= state << 5;
|
|
18
|
-
return state >>> 0;
|
|
19
|
-
};
|
|
20
|
-
const parityMode = new URL(location.href).searchParams.get('threeBlocksShaderMode');
|
|
21
|
-
if (parityMode === 'live' || parityMode === 'precompiled') {
|
|
22
|
-
root.__threeBlocksParityEpoch = 1700000000000;
|
|
23
|
-
root.__threeBlocksParityTime = 0;
|
|
24
|
-
Date.now = () => root.__threeBlocksParityEpoch + Number(root.__threeBlocksParityTime || 0);
|
|
25
|
-
}
|
|
26
|
-
const randomStreams = new Map();
|
|
27
|
-
Math.random = () => {
|
|
28
|
-
const stackLine = String(new Error().stack || '').split('\\n')[2] || 'unknown';
|
|
29
|
-
const originIndex = stackLine.indexOf(location.origin);
|
|
30
|
-
const callsite = (originIndex >= 0 ? stackLine.slice(0, originIndex) : stackLine).trim() || 'anonymous';
|
|
31
|
-
const next = advanceRandom(randomStreams.get(callsite) ?? randomSeed(scene + '|' + callsite));
|
|
32
|
-
randomStreams.set(callsite, next);
|
|
33
|
-
return next / 4294967296;
|
|
34
|
-
};
|
|
35
|
-
const readiness = { workerReady: false, assetsReady: false, textReady: false, compileEnd: false, firstFrame: false };
|
|
36
|
-
const stats = { buildCalls: 0, renderBuilds: 0, computeBuilds: 0, registeredBuilds: 0, registeredRenderBuilds: 0, registeredComputeBuilds: 0, buildMs: 0, syncBuildMs: 0, asyncBuildElapsedMs: 0, precompiledSetupMs: 0, maxSyncBuildMs: 0, maxPrecompiledSetupMs: 0, hydrationMs: 0, maxHydrationMs: 0, injected: 0, injectedRender: 0, injectedCompute: 0, missed: 0, missedRender: 0, missedCompute: 0, missedKeys: [] };
|
|
37
|
-
const settleParityFrames = ${ir.toString()};
|
|
38
|
-
const settle = (frames, requestedTarget) => settleParityFrames(
|
|
39
|
-
root,
|
|
40
|
-
frames,
|
|
41
|
-
requestedTarget,
|
|
42
|
-
() => new Promise((resolve) => requestAnimationFrame(resolve)),
|
|
43
|
-
() => new Promise((resolve) => setTimeout(resolve, 100)),
|
|
44
|
-
);
|
|
45
|
-
const bridge = { protocolVersion: 1, compatibility: ${JSON.stringify(t)}, transform: ${b$1}, readiness, stats, settle };
|
|
46
|
-
root.__threeBlocksShaderTools = bridge;
|
|
47
|
-
requestAnimationFrame(() => requestAnimationFrame(() => { readiness.firstFrame = true; }));
|
|
48
|
-
const poll = async () => {
|
|
49
|
-
try {
|
|
50
|
-
const response = await fetch('/__three-blocks/shaders/telemetry?scene=' + encodeURIComponent(scene), { cache: 'no-store' });
|
|
51
|
-
if (response.status !== 204 && response.ok) {
|
|
52
|
-
const payload = await response.json();
|
|
53
|
-
if (payload.protocolVersion !== 1 || payload.compatibility !== bridge.compatibility || payload.transform !== bridge.transform) throw new Error('incompatible shader telemetry');
|
|
54
|
-
Object.assign(stats, payload.stats);
|
|
55
|
-
if (Array.isArray(payload.demands)) bridge.demands = payload.demands;
|
|
56
|
-
if (typeof payload.demandTotal === 'number') bridge.demandTotal = payload.demandTotal;
|
|
57
|
-
readiness.workerReady = true;
|
|
58
|
-
if (payload.settled === true) {
|
|
59
|
-
readiness.assetsReady = true;
|
|
60
|
-
readiness.textReady = true;
|
|
61
|
-
readiness.compileEnd = true;
|
|
62
|
-
}
|
|
63
|
-
const smoke = root.__threeBlocksSmoke && typeof root.__threeBlocksSmoke === 'object' ? root.__threeBlocksSmoke : { protocolVersion: 1, worker: { offscreenCanvas: true, visible: true }, readiness: {} };
|
|
64
|
-
smoke.readiness = { ...(smoke.readiness || {}), ...readiness };
|
|
65
|
-
root.__threeBlocksSmoke = smoke;
|
|
66
|
-
}
|
|
67
|
-
} catch {}
|
|
68
|
-
setTimeout(poll, 40);
|
|
69
|
-
};
|
|
70
|
-
void poll();
|
|
71
|
-
})();`}a(le,"publicBridgeScript");function Le(t,e,r,n,a=false){let s=new URL(t.url??"/","http://three-blocks.invalid"),o=s.pathname;if(a&&t.method==="GET"&&/^\/three-blocks\/shaders\/[a-z0-9][a-z0-9_-]{0,63}\.(?:webgpu|webgl)\.json$/u.test(o))return e.statusCode=204,e.end(),true;if(o===z&&t.method==="GET"){let h=s.searchParams.get("scene")??"",S=n.read(h);return S===void 0?(e.statusCode=204,e.end()):(e.statusCode=200,e.setHeader("Content-Type","application/json"),e.end(JSON.stringify(S))),true}let i=o===Be,l=o===z;if(!i&&!l)return false;if(t.method!=="POST")return e.statusCode=405,e.end("POST required"),true;let u=[],p=0,f=false;return t.on("data",h=>{p+=h.byteLength,p>Oe?f=true:u.push(h);}),t.on("end",()=>{if(f){e.statusCode=413,e.end("capture payload too large");return}try{let h=JSON.parse(Buffer.concat(u).toString("utf8"));l?n.receive(h):r.receive(h),e.statusCode=204,e.end();}catch(h){e.statusCode=400,e.end(h instanceof Error?h.message:String(h));}}),true}a(Le,"handleCaptureEndpoint");function dr(t,e,r,n,a){return {name:"three-blocks:shader-capture-endpoint",transformIndexHtml(){return [{tag:"script",children:le(n,a),injectTo:"head-prepend"}]},configureServer(s){s.middlewares.use((o,i,l)=>{let p=new URL(o.url??"/","http://three-blocks.invalid").searchParams.get("captureId");p!==null&&e.markFirstRequest(p),!Le(o,i,t,e,r)&&l();});}}}a(dr,"captureEndpointPlugin");function Ee(t,e,r){let n=new URL(e.url,t);for(let[a,s]of Object.entries(r))n.searchParams.set(a,s);return n.href}a(Ee,"browserUrl");function lr(t,e,r){let n=new URL(e.url,t);for(let a of ["capture","precompiled"])n.searchParams.delete(a);return n.searchParams.set("captureId",e.key),n.searchParams.set("threeBlocksShaderCapture","1"),n.searchParams.set("threeBlocksShaderMode","precompiled"),r==="webgl"&&n.searchParams.set("webgl","1"),n.searchParams.set("tbStats","1"),n.href}a(lr,"publishedBrowserUrl");async function M(t){let e;try{await Promise.race([t(),new Promise(r=>{e=setTimeout(r,je);})]);}catch{}finally{e&&clearTimeout(e);}}a(M,"closeBrowserResource");async function q(t){let e;try{return await Promise.race([t().catch(()=>null),new Promise(r=>{e=setTimeout(()=>r(null),je);})])}finally{e!==void 0&&clearTimeout(e);}}a(q,"readPageDiagnostic");function ae(t){let e=a(()=>{},"resolveFirst"),r=new Promise(u=>{e=u;}),n=a(()=>{},"removeBrowserListener"),a$1={console:[],page:[],first:r,dispose:a(()=>n(),"dispose")},s=false,o=a(u=>{s||(s=true,e(new Error(u)));},"report"),i=t.context().browser(),l=a(()=>o("Shader browser disconnected before observation completed."),"onDisconnected");return i?.on("disconnected",l),n=a(()=>{i?.off("disconnected",l);},"removeBrowserListener"),t.on("console",u=>{let p=u.type()==="warning"&&/\[three-blocks\/shaders\].*(?:has no entry|manifest miss|hydration)/iu.test(u.text());if(u.type()!=="error"&&!p||a$4(u.text()))return;let f=u.location().url,h=f.length>0?`${u.text()} (${f})`:u.text();a$1.console.push(h),o(`Browser console ${p?"warning":"error"}: ${h}`);}),t.on("pageerror",u=>{if(a$4(u.message))return;let p=u.stack||u.message;a$1.page.push(p),o(`Browser page error: ${p}`);}),t.on("crash",()=>o("Browser page crashed before shader capture completed.")),t.on("close",()=>o("Browser page closed before shader capture completed.")),a$1}a(ae,"collectErrors");function N(t,e,r=false){return typeof t[e]=="boolean"?t[e]:r}a(N,"booleanField");function ur(t){if(!a$2(t))throw new Error("Browser shader stats are unavailable.");let e=a((r,n=true)=>{let a=t[r];if(typeof a!="number"||!Number.isFinite(a)||a<0||n&&!Number.isSafeInteger(a))throw new Error(`Browser shader stats.${r} is invalid.`);return a},"read");return {buildCalls:e("buildCalls"),renderBuilds:e("renderBuilds"),computeBuilds:e("computeBuilds"),registeredBuilds:e("registeredBuilds"),registeredRenderBuilds:e("registeredRenderBuilds"),registeredComputeBuilds:e("registeredComputeBuilds"),buildMs:e("buildMs",false),syncBuildMs:e("syncBuildMs",false),asyncBuildElapsedMs:e("asyncBuildElapsedMs",false),precompiledSetupMs:e("precompiledSetupMs",false),maxSyncBuildMs:e("maxSyncBuildMs",false),maxPrecompiledSetupMs:e("maxPrecompiledSetupMs",false),hydrationMs:e("hydrationMs",false),maxHydrationMs:e("maxHydrationMs",false),injected:e("injected"),injectedRender:e("injectedRender"),injectedCompute:e("injectedCompute"),missed:e("missed"),missedRender:e("missedRender"),missedCompute:e("missedCompute"),...Array.isArray(t.missedKeys)&&t.missedKeys.every(r=>typeof r=="string")?{missedKeys:t.missedKeys}:{}}}a(ur,"parseStats");function K(t,e,r,n,a){if(!a$2(t))throw new Error("The page did not expose the public shader devtools bridge.");if(!r&&t.protocolVersion!==1)throw new Error(`Scene "${e.key}" exposed an unsupported shader bridge protocol.`);let s=t.readiness;if(!a$2(s))throw new Error("The shader bridge readiness snapshot is invalid.");let o={workerReady:N(s,"workerReady"),assetsReady:N(s,"assetsReady"),textReady:e.requiresText?N(s,"textReady"):true,compileEnd:N(s,"compileEnd"),firstFrame:N(s,"firstFrame",r)};if(!o.workerReady||!o.assetsReady||!o.textReady||!o.compileEnd)throw new Error(`Scene "${e.key}" did not reach worker/assets/text/compile readiness.`);let i=r?a:t.compatibility,l=r?b$1:t.transform;if(i!==a||l!==b$1)throw new Error(`Scene "${e.key}" exposed incompatible shader bridge metadata.`);ne(n);let u=Array.isArray(t.demands)?t.demands.filter(a$2).slice(0,64):void 0;return {compatibility:a,transform:l,readiness:o,stats:ur(t.stats),...u===void 0?{}:{demands:u}}}a(K,"parseBridge");async function J(t,e){return t.evaluate(r=>{let n=globalThis;if(!r)return n.__threeBlocksShaderTools??null;let a=n.__threeBlocks,s=n.__threeBlocksTslStats;if(!a||typeof a!="object")return null;let o=a;return {readiness:{workerReady:o.workerReady===true,assetsReady:o.loadEnd===true||o.assetsReady===true,textReady:o.textReady===true,compileEnd:o.compileEnd===true,firstFrame:true},stats:s}},e)}a(J,"readBridge");async function Ie(t,e){let r=await q(()=>t.evaluate(n=>{let a$1=globalThis,s=a(i=>{let l=a$1;for(let u of i.split(".")){if(l===null||typeof l!="object"&&typeof l!="function")return;l=Reflect.get(l,u);}return l},"resolveGlobal"),o=null;if(n!==null)try{o=JSON.stringify(s(`${n}Diagnostics`))??null;}catch{o=null;}return JSON.stringify({parityCompletedFrame:Number(a$1.__threeBlocksParityCompletedFrame??0),diagnostics:o})},e??null));return r===null?{alive:false,signature:""}:{alive:true,signature:r}}a(Ie,"probePageProgress");async function U(t,e,r,n){let a$1=t.evaluate(async u=>{let f=globalThis.__threeBlocksShaderTools;if(f&&typeof f=="object"){let g=Reflect.get(f,"settle");if(typeof g=="function"){let c=await g(u.frames,u.targetFrame);return typeof c=="number"&&Number.isSafeInteger(c)?c:0}}if(!u.legacy||!u.modulePath)throw new Error("The public shader bridge does not provide deterministic settle().");let h=await import(u.modulePath);if(!h.store||typeof h.store!="object")throw new Error("Legacy deterministic store is unavailable.");let S=h.store;return S.recordFrameCount=0,S.recordFrameRate=60,S.recordTotalFrames=u.frames,S.recording=true,await new Promise((g,c)=>{let y=Date.now(),m=a(()=>{if(S.recording===false)return g();if(Date.now()-y>u.timeoutMs)return c(new Error("Legacy deterministic settle timed out."));setTimeout(m,25);},"poll");m();}),0},{frames:r,targetFrame:n,legacy:e.bridge.legacyLab,modulePath:e.bridge.deterministicModule??null,timeoutMs:e.timeoutMs}),s=j(e),o=false,i,l=(async()=>{let u=Date.now(),p=u,f="";for(;;){let h=s-(Date.now()-u);if(h<=0)throw new Error(`Shader parity settle timed out after ${s}ms.`);let S=e.timeoutMs-(Date.now()-p);if(S<=0){let g=await Ie(t,e.readiness.global);if(o)throw new Error("Shader parity settle already resolved.");if(g.alive&&g.signature===f)throw new Error(`Shader parity settle timed out after ${e.timeoutMs}ms without progress (hard cap ${s}ms).`);f=g.signature,p=Date.now();continue}if(await new Promise(g=>{i=setTimeout(g,Math.min(S,h,2500));}),o)throw new Error("Shader parity settle already resolved.")}})();try{return await Promise.race([a$1,l])}finally{o=true,i!==void 0&&clearTimeout(i),l.catch(()=>{});}}a(U,"settlePage");async function ke(t,e,r){e.readiness.selector===void 0&&e.readiness.global===void 0||await Promise.race([t.waitForFunction(n=>{let a=globalThis;if(n.selector!==void 0&&a.document?.querySelector(n.selector)==null)return false;if(n.global===void 0)return true;let s=a;for(let l of n.global.split(".")){if((typeof s!="object"||s===null)&&typeof s!="function")return false;s=Reflect.get(s,l);}if(s===true)return true;if(typeof s!="object"||s===null||typeof Reflect.get(s,"then")!="function")return false;let o=a.__threeBlocksReadinessState,i=o instanceof Map?o:new Map;return o instanceof Map||(a.__threeBlocksReadinessState=i),i.has(s)||(i.set(s,false),Promise.resolve(s).then(()=>i.set(s,true),()=>i.set(s,false))),i.get(s)===true},e.readiness,{timeout:j(e)}),r.first.then(n=>Promise.reject(n))]);}a(ke,"waitForConfiguredReadiness");async function Ce(t){let e=t.locator("canvas"),n=(await e.evaluateAll(a=>a.map((s,o)=>{let i=s.getBoundingClientRect();return {index:o,area:Math.max(0,i.width)*Math.max(0,i.height)}}))).sort((a,s)=>s.area-a.area)[0];if(n===void 0||n.area<=0)throw new Error("Published page has no visible renderer canvas.");return Buffer.from(await e.nth(n.index).screenshot({type:"png"}))}a(Ce,"primaryCanvasScreenshot");async function oe(t,e,r,n,a,s,o){let i=Y(n,a,s),l=await ve(),u=`(() => {
|
|
72
|
-
const runtime = globalThis[Symbol.for(${JSON.stringify(ee)})];
|
|
73
|
-
if (!runtime || typeof runtime.configureThreeBlocksShaderCapture !== 'function') {
|
|
74
|
-
throw new Error('@three-blocks/devtools attached shader capture runtime is incompatible.');
|
|
75
|
-
}
|
|
76
|
-
runtime.configureThreeBlocksShaderCapture(${JSON.stringify(i).replaceAll("<","\\u003c")});
|
|
77
|
-
})();`;await t.addInitScript({content:`${l}
|
|
78
|
-
${u}`}),await t.addInitScript({content:le(o,i)}),await t.route("**/*",async p=>{let f=p.request(),h=new URL(f.url()),S=h.pathname;if(f.method()==="GET"&&n!=="precompiled"&&/^\/three-blocks\/shaders\/[a-z0-9][a-z0-9_-]{0,63}\.(?:webgpu|webgl)\.json$/u.test(S)){await p.fulfill({status:204});return}if(S===z&&f.method()==="GET"){let y=r.read(h.searchParams.get("scene")??"");await p.fulfill(y===void 0?{status:204}:{status:200,contentType:"application/json",body:JSON.stringify(y)});return}let g=S===Be,c=S===z;if((g||c)&&f.method()==="POST"){let y=f.postDataBuffer()??Buffer.alloc(0);if(y.byteLength>Oe){await p.fulfill({status:413,body:"capture payload too large"});return}try{let m=JSON.parse(y.toString("utf8"));c?r.receive(m):e.receive(m),await p.fulfill({status:204});}catch(m){await p.fulfill({status:400,body:m instanceof Error?m.message:String(m)});}return}await p.continue();});}a(oe,"configureAttachedContext");var cr=Object.freeze({".avif":"image/avif",".css":"text/css; charset=utf-8",".gif":"image/gif",".html":"text/html; charset=utf-8",".ico":"image/x-icon",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"text/javascript; charset=utf-8",".json":"application/json; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".mp4":"video/mp4",".png":"image/png",".svg":"image/svg+xml",".wasm":"application/wasm",".webm":"video/webm",".webp":"image/webp",".woff":"font/woff",".woff2":"font/woff2"});function hr(t){let e=[`<script src="${Ae}"></script>`,`<script type="module" src="${Me}"></script>`].join(""),r=/<head(?:\s[^>]*)?>/iu.exec(t);return r===null?`${e}${t}`:`${t.slice(0,r.index+r[0].length)}${e}${t.slice(r.index+r[0].length)}`}a(hr,"injectStaticShaderCaptureHtml");function mr(t,e,r){let n=Y(t,e,r);return [`import { configureThreeBlocksShaderCapture } from ${JSON.stringify(xe)};`,`configureThreeBlocksShaderCapture( ${JSON.stringify(n).replaceAll("<","\\u003c")} );`].join(`
|
|
79
|
-
`)}a(mr,"staticCaptureBootstrap");var pr=5e3;function j(t){return Math.max(t.maxTimeoutMs??t.timeoutMs,t.timeoutMs)}a(j,"configuredHardCapMs");function Y(t,e,r){return {capture:t==="capture",backend:r,driven:true,forceLive:t!=="precompiled",settleFrames:e.settleFrames,settleTimeoutMs:e.settleTimeoutMs??3e4,...t==="capture"?{deadlineAt:Date.now()+Math.max(1e3,j(e)-pr)}:{},readiness:e.readiness,transform:b$1}}a(Y,"shaderCaptureConfiguration");async function fr(t,e){let r=await k(t,e,o=>/\.(?:c|m)?js$/u.test(o),16384),n=false,a=false,s;for(let o of r){let i=(await j$1(t,o,a$1.texture,"Static application JavaScript")).data.toString("utf8");if(i.includes("nodeBuilderStateProvider")&&(n=true),i.includes("three-blocks.shader-capture.runtime.v1")&&(a=true,s??=o),n&&a)break}if(!n||!a)throw new Error("The static build does not contain the Three.js shader capture transform. Run `shaders capture` without an explicit driver or URL to preview adapter wiring and build automatically, or add the manual adapter from the package README and rebuild.");return {seen:true,applied:true,alreadyPresent:false,captureApplied:true,...s===void 0?{}:{id:s}}}a(fr,"inspectStaticCaptureTransform");async function yr(t,e$1){let r;try{r=decodeURIComponent(e$1);}catch{return}if(r.includes("\0"))return;let n=r.replace(/^\/+/u,""),a=O.resolve(t,n.length===0?"index.html":n);if(!e(t,a)||a===t||(await d$1(a)&&(await lstat(a)).isDirectory()&&(a=O.join(a,"index.html")),!await d$1(a)&&O.extname(a).length===0&&(a=O.join(t,"index.html")),!await d$1(a)))return;let s=await j$1(t,a,a$1.texture,"Static application asset");return {data:s.data,file:s.path}}a(yr,"staticRequestFile");async function wr(t,e$1,r,n,a,s){let o=await realpath(t.root),i=await realpath(O.resolve(o,t.serve));if(!e(o,i)||i===o)throw new Error("--serve must name a built application directory inside the project root.");let l=await fr(o,i),u=await I(),p=mr(e$1,n,r),f=le(a$3(t.runtime.three,r),Y(e$1,n,r)),h=createServer((g,c)=>{(async()=>{if(Le(g,c,a,s,e$1!=="precompiled"))return;let y=new URL(g.url??"/","http://three-blocks.invalid");if(g.method!=="GET"&&g.method!=="HEAD"){c.statusCode=405,c.end("GET or HEAD required");return}let m=y.pathname===xe?u:y.pathname===Me?p:y.pathname===Ae?f:void 0;if(m!==void 0){c.statusCode=200,c.setHeader("Content-Type","text/javascript; charset=utf-8"),c.setHeader("Cache-Control","no-store"),c.end(g.method==="HEAD"?void 0:m);return}let w=await yr(i,y.pathname);if(w===void 0){c.statusCode=404,c.end("Not found");return}let v=O.extname(w.file).toLowerCase(),b=v===".html"?Buffer.from(hr(w.data.toString("utf8"))):w.data;c.statusCode=200,c.setHeader("Content-Type",cr[v]??"application/octet-stream"),c.setHeader("Content-Length",String(b.byteLength)),c.setHeader("Cache-Control","no-store"),c.end(g.method==="HEAD"?void 0:b);})().catch(y=>{if(c.headersSent)return c.destroy(y instanceof Error?y:void 0);c.statusCode=500,c.end(y instanceof Error?y.message:String(y));});});await new Promise((g,c)=>{h.once("error",c),h.listen(0,"127.0.0.1",()=>{h.off("error",c),g();});});let S=h.address();if(!S||typeof S=="string")throw new Error("Static capture server did not expose an ephemeral TCP address.");return {server:h,baseUrl:`http://127.0.0.1:${S.port}`,transform:l}}a(wr,"startStaticShaderServer");function gr(t,e,r){return t===e?true:r&&t!==void 0&&t!=="capture"&&e!=="capture"}a(gr,"canReuseShaderBrowserSession");function _e(t){let e=t instanceof Error?t.message:String(t);return e.includes("Execution context was destroyed")&&e.includes("navigation")||/^launch: Timeout \d+ms exceeded\./u.test(e)||e.includes("Shader browser disconnected before observation completed.")}a(_e,"isRetryableShaderObservationNavigation");var H=class{static{a(this,"PlaywrightShaderDriver");}#e;#r=new ie;#n=new de;#h;#m;#s;#i;#t;#a;#p;#l;#f;#y;#u=0;#c;constructor(e){this.#e=e;}#d(){return this.#h?.status??this.#m??{seen:false,applied:false,alreadyPresent:false}}async#w(e,r){if(this.#t?.isConnected()===true)return;this.#t=void 0;let n=await ar();this.#c??=await mkdtemp(O.join(tmpdir(),"three-blocks-shader-cache-"));let a=n.launch({headless:r==="webgl"?this.#e.headed!==true:d(this.#e.headed===true),args:[...r==="webgl"?c():b(),`--disk-cache-dir=${this.#c}`],timeout:e.timeoutMs}),s;try{this.#t=await Promise.race([a,new Promise((o,i)=>{s=setTimeout(()=>i(new Error(`launch: Timeout ${e.timeoutMs}ms exceeded.`)),e.timeoutMs);})]);}catch(o){throw a.then(i=>M(()=>i.close()),()=>{}),o}finally{s!==void 0&&clearTimeout(s);}this.#u=0;}async#o(e,r,n){let a;try{return await Promise.race([n(),new Promise((s,o)=>{a=setTimeout(()=>o(new Error(`launch: Timeout ${r.timeoutMs}ms exceeded.`)),r.timeoutMs);})])}catch(s){throw this.#t===e&&(this.#t=void 0),await M(()=>e.close()),s}finally{a!==void 0&&clearTimeout(a);}}async#g(e,r,n){let a=this.#s!==void 0||this.#i!==void 0||this.#e.url!==void 0&&this.#a!==void 0,s=this.#f===r&&(this.#i!==void 0?this.#l===e:gr(this.#l,e,n.bridge.legacyLab));if(a&&s){this.#l=e,await this.#w(n,r);return}if(a&&await this.close(),this.#l=e,this.#f=r,this.#e.url!==void 0){let o=new URL(this.#e.url);if(!["http:","https:"].includes(o.protocol)||o.username||o.password||o.hash)throw new Error("Attached shader URL must be an HTTP(S) URL without credentials or a fragment.");this.#a=o.href,this.#m={seen:true,applied:true,alreadyPresent:false,captureApplied:true,id:"attached-application"},await this.#w(n,r);return}if(this.#e.serve!==void 0)try{let o=await wr({root:this.#e.root,runtime:this.#e.runtime,serve:this.#e.serve,...this.#e.headed===void 0?{}:{headed:this.#e.headed}},e,r,n,this.#r,this.#n);this.#i=o.server,this.#m=o.transform,this.#a=o.baseUrl,await this.#w(n,r);return}catch(o){throw await this.close(),o}this.#h=Re(this.#e.runtime.three,{disableTimestampQueries:x.env.THREE_BLOCKS_SOFTWARE_WEBGPU==="1",...n.bridge.legacyLab?{}:{capture:{capture:e==="capture",driven:true,forceLive:e!=="precompiled",forceWebGL:r==="webgl",settleFrames:n.settleFrames,settleTimeoutMs:n.settleTimeoutMs??3e4,readiness:n.readiness}}}),this.#p={THREE_BLOCKS_SHADER_TOOL:x.env.THREE_BLOCKS_SHADER_TOOL,THREE_BLOCKS_PRECOMPILE_CAPTURE_SERVER:x.env.THREE_BLOCKS_PRECOMPILE_CAPTURE_SERVER},x.env.THREE_BLOCKS_SHADER_TOOL="1",x.env.THREE_BLOCKS_PRECOMPILE_CAPTURE_SERVER="1";try{let o=await or(this.#e.root);this.#s=await o({root:this.#e.root,logLevel:"error",plugins:[this.#h.plugin,dr(this.#r,this.#n,e!=="precompiled",a$3(this.#e.runtime.three,r),Y(e,n,r))],server:{host:"127.0.0.1",port:0}}),await this.#s.listen();let i=this.#s.httpServer?.address();if(!i||typeof i=="string")throw new Error("Vite did not expose an ephemeral TCP address.");this.#a=`http://127.0.0.1:${i.port}`,await this.#w(n,r);}catch(o){throw await this.close(),o}}async capture(e,r,n="webgpu"){let a$1=Date.now();if(await this.#g("capture",n,r),!this.#t||!this.#a)throw new Error("Shader browser driver did not start.");let s=this.#t,o=await this.#o(s,r,()=>s.newContext({viewport:r.viewport}));this.#e.url!==void 0&&await this.#o(s,r,()=>oe(o,this.#r,this.#n,"capture",r,n,a$3(this.#e.runtime.three,n)));let i=await this.#o(s,r,()=>o.newPage()),l=ae(i);this.#n.clear(e.key);let u=j(r),p=this.#r.wait(e.key,u),f=false;u>r.timeoutMs?(async()=>{let m=Math.min(5e3,Math.max(1e3,Math.round(r.timeoutMs/8))),w=Date.now(),v="",b="";for(;!f;){if(await new Promise(P=>setTimeout(P,m)),f)return;let R=this.#n.read(e.key),_=R===void 0?"":JSON.stringify(R);if(_!==v){v=_,w=Date.now();continue}if(Date.now()-w<r.timeoutMs)continue;let E=await Ie(i,r.readiness.global);if(f)return;if(!E.alive||E.signature!==b){b=E.signature,w=Date.now();continue}this.#r.cancel(e.key,new Error(`Shader capture "${e.key}" timed out after ${r.timeoutMs}ms without progress (hard cap ${u}ms).`));return}})().catch(()=>{}):void 0;let S=Promise.race([p,l.first.then(m=>Promise.reject(m))]),g=a(()=>{},"resolveDisconnected"),c=new Promise(m=>{g=m;}),y=a(()=>g(new Error("Shader capture browser disconnected before posting a manifest.")),"onDisconnected");s.on("disconnected",y);try{let m=i.goto(Ee(this.#a,e,{threeBlocksShaderCapture:"1",capture:"1",captureId:e.key,captureFrames:String(Math.max(4,r.settleFrames)),settleFrames:String(r.settleFrames),...n==="webgl"?{webgl:"1"}:{}}),{waitUntil:"domcontentloaded",timeout:r.timeoutMs}),w=await sr(m,Promise.race([S,c.then(b=>Promise.reject(b))]));ne(this.#d());let v=[...l.page,...l.console];if(v.length>0)throw new Error(`Capture browser errors:
|
|
80
|
-
- ${v.join(`
|
|
81
|
-
- `)}`);return a$2(w)?{...w,timing:{...a$2(w.timing)?w.timing:{},launch:a$1,...this.#n.firstRequest(e.key)===void 0?{}:{firstRequest:this.#n.firstRequest(e.key)},posted:Date.now()}}:w}catch(m){let w=m instanceof Error?m:new Error(String(m));this.#r.cancel(e.key,w),await p.catch(()=>{});let v=this.#n.read(e.key);if(w.message.includes("timed out")){let b=await q(()=>i.evaluate(E=>{let P=globalThis,G=P.__threeBlocksShaderTools,Fe=G&&typeof G=="object"?G:void 0,$e=P.document,A=Reflect.get(P,Symbol.for("three-blocks.shader-capture.cache-value.v1")),W=P.location,Ne=W!==null&&typeof W=="object"&&typeof Reflect.get(W,"href")=="string"?String(Reflect.get(W,"href")):"http://three-blocks.invalid/",Ue=new URL(Ne).searchParams.get("captureId")??"default",ue=A!==null&&typeof A=="object"&&typeof Reflect.get(A,"registrations")=="function"?Reflect.apply(Reflect.get(A,"registrations"),A,[Ue]):void 0,ce=a(T=>{let B=P;for(let He of T.split(".")){if(B===null||typeof B!="object"&&typeof B!="function")return;B=Reflect.get(B,He);}return B},"resolveGlobal"),he=null,Q=null;if(E!==null){let T=ce(E);he=T===true||T===false?T:T===void 0?"absent":T!==null&&typeof T.then=="function"?"promise":typeof T;try{let B=JSON.stringify(ce(`${E}Diagnostics`));Q=typeof B=="string"?B.slice(0,2048):null;}catch{Q=null;}}return {documentReadyState:$e?.readyState??null,parityTargetFrame:Number(P.__threeBlocksParityTargetFrame??0),parityCompletedFrame:Number(P.__threeBlocksParityCompletedFrame??0),readiness:Fe?.readiness??null,readinessGlobal:he,readinessDiagnostics:Q,captureCache:A!==null&&typeof A=="object"?{activeScene:Reflect.get(A,"activeScene")??null,registrations:Array.isArray(ue)?ue.slice(0,16).map(T=>T!==null&&typeof T=="object"?{key:Reflect.get(T,"key")??null,kind:Reflect.get(T,"kind")??null}:null):null}:null,threeRuntimeResources:performance.getEntriesByType("resource").map(T=>T.name).filter(T=>T.includes("three.webgpu"))}},r.readiness.global??null)),R=r.readiness.global!==void 0&&b!==null&&b.readinessGlobal!==true,_=b===null?"Capture page did not answer diagnostics before the deadline; its main thread was blocked or gone. ":R?`Application readiness "${r.readiness.global}" never completed (state: ${JSON.stringify(b.readinessGlobal)}${b.readinessDiagnostics===null?"":`, diagnostics: ${b.readinessDiagnostics}`}). `:"";throw new Error(`${_}${w.message} Last capture state for "${e.key}": ${JSON.stringify({page:b,telemetry:v??null,transform:this.#d()})}`)}throw w}finally{f=true,l.dispose(),s.off("disconnected",y),await M(()=>o.close()),this.#u++,(!s.isConnected()||this.#u>=(r.browserRelaunchScenes??8))&&(this.#t===s&&(this.#t=void 0),await M(()=>s.close()),this.#u=0);}}async observe(e,r,n,a,s="webgpu"){for(let o=0;o<2;o++)try{return await this.#S(e,s,r,n,a)}catch(i){if(o===0&&_e(i))continue;throw i}throw new Error(`Shader observation retry was exhausted for scene "${e.key}".`)}async#S(e,r,n,a,s){if(await this.#g(n,r,a),!this.#t||!this.#a)throw new Error("Shader browser driver did not start.");let o=this.#t,i=await this.#o(o,a,()=>o.newContext({viewport:a.viewport}));this.#e.url!==void 0&&await this.#o(o,a,()=>oe(i,this.#r,this.#n,n,a,r,a$3(this.#e.runtime.three,r)));let l=await this.#o(o,a,()=>i.newPage()),u=ae(l);this.#n.clear(e.key);try{await l.goto(Ee(this.#a,e,{threeBlocksShaderCapture:"1",threeBlocksShaderMode:n,captureId:e.key,...n==="live"?{precompiled:"0"}:{},...r==="webgl"?{webgl:"1"}:{}}),{waitUntil:"domcontentloaded",timeout:a.timeoutMs}),await Promise.race([l.waitForFunction(a.bridge.legacyLab?"globalThis.__threeBlocks?.compileEnd === true":"globalThis.__threeBlocksShaderTools?.readiness?.compileEnd === true",void 0,{timeout:j(a)}),u.first.then(c=>Promise.reject(c))]),K(await J(l,a.bridge.legacyLab),e,a.bridge.legacyLab,this.#d(),a$3(this.#e.runtime.three,r)),await ke(l,a,u),await Promise.race([l.waitForFunction(a.bridge.legacyLab?"true":"globalThis.__threeBlocksShaderTools?.readiness?.firstFrame === true",void 0,{timeout:j(a)}),u.first.then(c=>Promise.reject(c))]),await U(l,a,1);let p=Buffer.from(await l.screenshot({type:"png",timeout:a.timeoutMs})),f=e.parityFrames??a.parity.frames,h=await U(l,a,f,s),S=Buffer.from(await l.screenshot({type:"png",timeout:a.timeoutMs}));e.parityFrames!==void 0&&f<a.parity.frames&&await U(l,a,a.parity.frames-f);let g=K(await J(l,a.bridge.legacyLab),e,a.bridge.legacyLab,this.#d(),a$3(this.#e.runtime.three,r));return this.#y===void 0&&(this.#y=await l.evaluate(async c=>{if(c==="webgl"){let E=Reflect.get(globalThis,"document").querySelector("canvas")?.getContext("webgl2"),P=E?.getExtension("WEBGL_debug_renderer_info");return {adapter:E&&P?String(E.getParameter(P.UNMASKED_RENDERER_WEBGL)):"WebGL adapter",platform:navigator.platform||navigator.userAgent}}let y=Reflect.get(navigator,"gpu"),m=typeof y=="object"&&y!==null?Reflect.get(y,"requestAdapter"):void 0,w=typeof m=="function"?await Reflect.apply(m,y,[]):void 0,v=typeof w=="object"&&w!==null?Reflect.get(w,"info"):void 0,b=["description","device","architecture","vendor"].flatMap(R=>{let _=typeof v=="object"&&v!==null?Reflect.get(v,R):void 0;return typeof _=="string"&&_.length>0?[_]:[]});return {adapter:[...new Set(b)].join(" \xB7 ")||"WebGPU adapter",platform:navigator.platform||navigator.userAgent}},r)),{scene:e.key,mode:n,...g,frame:h,firstFrameScreenshot:p,screenshot:S,errors:[...u.page,...u.console]}}catch(p){let f=p instanceof Error?p:new Error(String(p));if(/(?:timed?\s*out|timeout)/iu.test(f.message)){let c=this.#n.read(e.key),y=await q(()=>l.evaluate(()=>{let m=globalThis,w=m.__threeBlocksShaderTools,v=w&&typeof w=="object"?w:void 0;return {documentReadyState:m.document?.readyState??null,parityTargetFrame:Number(m.__threeBlocksParityTargetFrame??0),parityCompletedFrame:Number(m.__threeBlocksParityCompletedFrame??0),readiness:v?.readiness??null,threeRuntimeResources:performance.getEntriesByType("resource").map(R=>R.name).filter(R=>R.includes("three.webgpu"))}}));throw new Error(`${f.message} Last ${n} state for "${e.key}": ${JSON.stringify({page:y,telemetry:c??null})}`)}let h=this.#n.read(e.key),g=(a$2(h)&&Array.isArray(h.demands)&&h.demands.length>0?JSON.stringify(h.demands).slice(0,6e3):void 0)??await q(()=>l.evaluate(c=>{let y=globalThis,m=Reflect.get(y,Symbol.for(c)),w=m!==null&&typeof m=="object"?Reflect.get(m,"readThreeBlocksShaderDemands"):void 0,v=typeof w=="function"?Reflect.apply(w,m,[]):void 0,b=y.__threeBlocksShaderTools,R=Array.isArray(v)&&v.length>0?v:b&&typeof b=="object"?Reflect.get(b,"demands"):void 0;return Array.isArray(R)&&R.length>0?JSON.stringify(R).slice(0,6e3):null},ee));throw typeof g=="string"?new Error(`${f.message}
|
|
82
|
-
${n} demands: ${g}`):f}finally{u.dispose(),await M(()=>i.close());}}async observePublished(e,r,n="webgpu"){for(let a=0;a<2;a++)try{return await this.#b(e,n,r)}catch(s){if(a===0&&_e(s))continue;throw s}throw new Error(`Published shader observation retry was exhausted for scene "${e.key}".`)}async#b(e,r,n){if(await this.#g("precompiled",r,n),!this.#t||!this.#a)throw new Error("Shader browser driver did not start.");let a=this.#t,s=await this.#o(a,n,()=>a.newContext({viewport:n.viewport}));this.#e.url!==void 0&&await this.#o(a,n,()=>oe(s,this.#r,this.#n,"precompiled",n,r,a$3(this.#e.runtime.three,r)));let o=await this.#o(a,n,()=>s.newPage()),i=ae(o);this.#n.clear(e.key);try{await o.goto(lr(this.#a,e,r),{waitUntil:"domcontentloaded",timeout:n.timeoutMs}),await Promise.race([o.waitForFunction(n.bridge.legacyLab?"globalThis.__threeBlocks?.compileEnd === true":"globalThis.__threeBlocksShaderTools?.readiness?.compileEnd === true",void 0,{timeout:j(n)}),i.first.then(h=>Promise.reject(h))]),await ke(o,n,i),K(await J(o,n.bridge.legacyLab),e,n.bridge.legacyLab,this.#d(),a$3(this.#e.runtime.three,r)),await U(o,n,2);let l=await Ce(o),u=await U(o,n,120),p=await Ce(o),f=K(await J(o,n.bridge.legacyLab),e,n.bridge.legacyLab,this.#d(),a$3(this.#e.runtime.three,r));return {scene:e.key,mode:"precompiled",...f,frame:u,firstFrameScreenshot:l,beforeScreenshot:l,screenshot:p,errors:[...i.page,...i.console]}}finally{i.dispose(),await M(()=>s.close());}}timingEnvironment(){return this.#y??{adapter:this.#f==="webgl"?"WebGL adapter":"WebGPU adapter",platform:`${x.platform}/${x.arch}`}}async close(){this.#r.rejectAll(new Error("Shader browser driver closed.")),this.#t&&await M(()=>this.#t?.close()??Promise.resolve());let e=this.#s?.httpServer,r=e?Reflect.get(e,"closeAllConnections"):void 0;if(e&&typeof r=="function"&&Reflect.apply(r,e,[]),this.#s&&await M(()=>this.#s?.close()??Promise.resolve()),this.#i){let n=this.#i;n.closeAllConnections(),await M(()=>new Promise(a=>{n.close(()=>a());}));}if(this.#t=void 0,this.#s=void 0,this.#i=void 0,this.#a=void 0,this.#h=void 0,this.#m=void 0,this.#l=void 0,this.#f=void 0,this.#y=void 0,this.#u=0,this.#c!==void 0&&(await rm(this.#c,{recursive:true,force:true}),this.#c=void 0),this.#p){for(let[n,a]of Object.entries(this.#p))a===void 0?delete x.env[n]:x.env[n]=a;this.#p=void 0;}}};function Jr(t){return new H(t)}a(Jr,"createPlaywrightShaderDriver");function qr(t){return new H(t)}a(qr,"createStaticPlaywrightShaderDriver");function zr(t){return new H(t)}a(zr,"createAttachedPlaywrightShaderDriver");export{sr as a,ir as b,le as c,gr as d,_e as e,Jr as f,qr as g,zr as h};
|
package/dist/chunk-7N6TU4JG.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {a as a$2}from'./chunk-ZT6T2W4B.js';import {e as e$1,g}from'./chunk-NPLE7PPF.js';import {a as a$1,c as c$1}from'./chunk-65VEJRRT.js';import {c,d as d$1,f,e,i}from'./chunk-5L2VS3BN.js';import {a}from'./chunk-HOZDD6PW.js';import {THREE_WEBGL_R185_COMPATIBILITY,THREE_WEBGPU_R185_COMPATIBILITY,THREE_R186DEV_VERSION,THREE_WEBGPU_R186DEV_COMPATIBILITY,parsePrecompiledManifest,SHADER_HYDRATION_SCHEMA_VERSION,SHADER_RECIPE_SCHEMA_VERSION,SHADER_ADDRESS_SCHEMA_VERSION,PRECOMPILED_MANIFEST_VERSION}from'three-blocks/shaders';import {lstat,readFile,unlink,mkdir,readdir}from'fs/promises';import d from'path';function v(e,r="webgpu"){if(/^0\.185\./u.test(e))return r==="webgl"?THREE_WEBGL_R185_COMPATIBILITY:THREE_WEBGPU_R185_COMPATIBILITY;if(e===THREE_R186DEV_VERSION&&r==="webgpu")return THREE_WEBGPU_R186DEV_COMPATIBILITY;throw new Error(`Three.js ${e} is outside the supported shader compatibility contracts.`)}a(v,"shaderCompatibilityForThree");var be=63,de="timing.local.json",ce="timing.json",q="parity.json",O=4096,Ee=4096;function W(e,r,n=8192){if(typeof e!="string"||e.length===0||e.length>n||/[\u0000\u007f]/u.test(e))throw new Error(`${r} must be a bounded non-empty string.`);return e}a(W,"boundedString");function p(e,r,n=true){if(typeof e!="number"||!Number.isFinite(e)||e<0||n&&!Number.isSafeInteger(e))throw new Error(`${r} must be a non-negative ${n?"integer":"finite number"}.`);return e}a(p,"nonNegativeNumber");function Re(e){if(!a$1(e))throw new Error("Shader capture stats are missing.");let r={buildCalls:p(e.buildCalls,"capture stats.buildCalls"),renderBuilds:p(e.renderBuilds,"capture stats.renderBuilds"),computeBuilds:p(e.computeBuilds,"capture stats.computeBuilds"),registeredBuilds:p(e.registeredBuilds,"capture stats.registeredBuilds"),registeredRenderBuilds:p(e.registeredRenderBuilds,"capture stats.registeredRenderBuilds"),registeredComputeBuilds:p(e.registeredComputeBuilds,"capture stats.registeredComputeBuilds"),buildMs:p(e.buildMs,"capture stats.buildMs",false),syncBuildMs:p(e.syncBuildMs,"capture stats.syncBuildMs",false),asyncBuildElapsedMs:p(e.asyncBuildElapsedMs,"capture stats.asyncBuildElapsedMs",false),precompiledSetupMs:p(e.precompiledSetupMs,"capture stats.precompiledSetupMs",false),maxSyncBuildMs:p(e.maxSyncBuildMs??e.syncBuildMs,"capture stats.maxSyncBuildMs",false),maxPrecompiledSetupMs:p(e.maxPrecompiledSetupMs??e.precompiledSetupMs,"capture stats.maxPrecompiledSetupMs",false),hydrationMs:p(e.hydrationMs??0,"capture stats.hydrationMs",false),maxHydrationMs:p(e.maxHydrationMs??e.hydrationMs??0,"capture stats.maxHydrationMs",false),injected:p(e.injected,"capture stats.injected"),injectedRender:p(e.injectedRender,"capture stats.injectedRender"),injectedCompute:p(e.injectedCompute,"capture stats.injectedCompute"),missed:p(e.missed,"capture stats.missed"),missedRender:p(e.missedRender,"capture stats.missedRender"),missedCompute:p(e.missedCompute,"capture stats.missedCompute"),...Array.isArray(e.missedKeys)&&e.missedKeys.every(n=>typeof n=="string")?{missedKeys:e.missedKeys.slice(0,O)}:{}};if(r.renderBuilds+r.computeBuilds!==r.buildCalls||r.registeredRenderBuilds+r.registeredComputeBuilds!==r.registeredBuilds||r.injectedRender+r.injectedCompute!==r.injected||r.missedRender+r.missedCompute!==r.missed||r.registeredBuilds>r.buildCalls||Math.abs(r.syncBuildMs+r.asyncBuildElapsedMs-r.buildMs)>.001||r.maxSyncBuildMs>r.syncBuildMs+.001||r.maxPrecompiledSetupMs>r.precompiledSetupMs+.001||r.maxHydrationMs>r.hydrationMs+.001)throw new Error("Shader capture stats totals are inconsistent.");return r}a(Re,"captureStats");function Me(e){if(!Array.isArray(e)||e.length>O)throw new Error("Shader capture skipped builds are invalid.");return e.map((r,n)=>{if(!a$1(r)||r.kind!=="render"&&r.kind!=="compute")throw new Error(`Shader capture skipped build ${n} is invalid.`);return {kind:r.kind,name:W(r.name,`skipped build ${n} name`,512),reason:W(r.reason,`skipped build ${n} reason`)}})}a(Me,"skippedBuilds");function ke(e){let r=0,n=0,t=0,i=0;for(let s of Object.values(e.entries)){let o=e.states[s];o!==void 0&&((o.vertex!==null||o.fragment!==null)&&r++,o.vertex!==null&&n++,o.fragment!==null&&t++,o.compute!==null&&i++);}return {render:r,vertex:n,fragment:t,compute:i}}a(ke,"shaderCoverage");function Le(e,r){if(!a$1(e))throw new Error("Shader capture payload must be an object.");if(e.scene!==r.scene)throw new Error(`Shader capture scene does not match "${r.scene}".`);if(e.protocolVersion!==2)throw new Error("Shader capture protocolVersion must be 2.");let n=r.backend??"webgpu",t=v(r.runtime.three,n);if(e.compatibility!==t)throw new Error(`Shader capture compatibility must be "${t}".`);if(!a$1(e.entries))throw new Error("Shader capture entries must be an object.");if(typeof e.requiresSetup!="boolean")throw new Error("Shader capture requiresSetup must be boolean.");let i=Object.keys(e.entries).length;if(i>O)throw new Error(`Shader capture must contain at most ${O} entries.`);if(!Array.isArray(e.errors)||e.errors.length>Ee)throw new Error("Shader capture errors are invalid.");let s=e.errors.map((w,a)=>W(w,`capture error ${a}`,64*1024));if(s.length>0)throw new Error(`Shader capture failed:
|
|
3
|
-
- ${s.join(`
|
|
4
|
-
- `)}`);let o=Me(e.skipped);if(i===0&&(n!=="webgl"||o.length===0))throw new Error("Shader capture must contain an entry unless WebGL explicitly skipped every live build.");let u=Re(e.stats),l=a$1(e.timing)?e.timing:void 0,g=l===void 0?void 0:Object.fromEntries(["launch","firstRequest","readiness","lastBuild","settled","posted"].flatMap(w=>{let a=l[w];if(a===void 0)return [];if(typeof a!="number"||!Number.isFinite(a)||a<0)throw new Error(`Shader capture timing.${w} is invalid.`);return [[w,a]]})),m;if(e.provenance!==void 0){if(!a$1(e.provenance)||typeof e.provenance.userAgent!="string"||e.provenance.userAgent.length>1024||typeof e.provenance.adapter!="string"||e.provenance.adapter.length>1024||!Array.isArray(e.provenance.features)||e.provenance.features.length>256||!e.provenance.features.every(w=>typeof w=="string"&&w.length<=128))throw new Error("Shader capture provenance is invalid.");m={userAgent:e.provenance.userAgent,adapter:e.provenance.adapter,features:[...new Set(e.provenance.features)].sort()};}let R=parsePrecompiledManifest({version:PRECOMPILED_MANIFEST_VERSION,scene:r.scene,three:r.runtime.three,threeBlocks:r.runtime.threeBlocks,runtime:{id:t,address:SHADER_ADDRESS_SCHEMA_VERSION,recipe:SHADER_RECIPE_SCHEMA_VERSION,hydration:SHADER_HYDRATION_SCHEMA_VERSION},...e.automatic===void 0?{}:{automatic:e.automatic},requiresSetup:e.requiresSetup,modules:e.modules,nodes:e.nodes,layouts:e.layouts,attributePlans:e.attributePlans,updatePlans:e.updatePlans,requirementPlans:e.requirementPlans,states:e.states,entries:e.entries,...e.fallbacks===void 0?{}:{fallbacks:e.fallbacks}}),S=ke(R);if(u.registeredRenderBuilds<S.render||u.registeredComputeBuilds<S.compute)throw new Error("Shader capture did not live-build every distinct registered render/compute entry.");return {scene:r.scene,backend:n,manifest:R,skipped:o,stats:u,coverage:S,...g===void 0?{}:{timing:g},...m===void 0?{}:{provenance:m}}}a(Le,"validateShaderCapture");function E(e,r=0){let n=" ".repeat(r),t=" ".repeat(r+1);if(Array.isArray(e))return e.length===0?"[]":e.every(s=>s===null||["number","string","boolean"].includes(typeof s))?JSON.stringify(e):`[
|
|
5
|
-
${e.map(s=>`${t}${E(s,r+1)}`).join(`,
|
|
6
|
-
`)}
|
|
7
|
-
${n}]`;if(e!==null&&typeof e=="object"){let s=e,o=Object.keys(s).sort();return o.length===0?"{}":`{
|
|
8
|
-
${o.map(u=>{let l=s[u];return `${t}${JSON.stringify(u)}: ${E(l,r+1)}`}).join(`,
|
|
9
|
-
`)}
|
|
10
|
-
${n}}`}let i=JSON.stringify(e);if(i===void 0)throw new Error("Shader artifact contains a non-serializable value.");return i}a(E,"stableStringify");function Be(e){return ["// GENERATED FILE \u2014 do not edit by hand.","// Produced by @three-blocks/devtools.","import type { PrecompiledManifest } from 'three-blocks/shaders';","",`export default ${E(e)} satisfies PrecompiledManifest;`,""].join(`
|
|
11
|
-
`)}a(Be,"serializeShaderManifest");function ee(e,r){if(typeof e!="string"||e.length===0||e.length>256||/[\u0000-\u001f\u007f]/u.test(e))throw new Error(`${r} is invalid.`);return e}a(ee,"timingLabel");function U(e){if(!a$1(e)||e.schemaVersion!==3||e.source!=="latest-local-capture"&&e.source!=="committed-capture"||typeof e.receiptHash!="string"||!/^[a-f0-9]{64}$/u.test(e.receiptHash)||typeof e.measuredAt!="string"||!Number.isFinite(Date.parse(e.measuredAt))||!a$1(e.scenes))throw new Error("Shader timing is invalid.");let r={};for(let[t,i]of Object.entries(e.scenes)){if(t.length===0||t.length>128||!a$1(i))throw new Error("Shader timing scene is invalid.");let s={builds:p(i.builds,`timing ${t}.builds`),setupMeasured:i.setupMeasured===true,liveBuildMs:p(i.liveBuildMs,`timing ${t}.liveBuildMs`,false),precompiledBuildMs:p(i.precompiledBuildMs,`timing ${t}.precompiledBuildMs`,false),avoidedBuildMs:p(i.avoidedBuildMs,`timing ${t}.avoidedBuildMs`,false),runs:p(i.runs,`timing ${t}.runs`),spreadMs:p(i.spreadMs,`timing ${t}.spreadMs`,false)};if(s.runs<1)throw new Error(`Shader timing runs are invalid for scene "${t}".`);if(Math.abs(s.avoidedBuildMs-Math.max(0,s.liveBuildMs-s.precompiledBuildMs))>.001)throw new Error(`Shader timing delta is inconsistent for scene "${t}".`);r[t]=s;}if(Object.keys(r).length===0)throw new Error("Shader timing contains no scenes.");let n={schemaVersion:3,receiptHash:e.receiptHash,measuredAt:e.measuredAt,scenes:r};return e.source==="latest-local-capture"?{...n,source:"latest-local-capture"}:{...n,source:"committed-capture",adapter:ee(e.adapter,"Shader timing adapter"),platform:ee(e.platform,"Shader timing platform")}}a(U,"parseShaderTiming");function _(e){return /^[a-z0-9][a-z0-9_-]{0,63}(?:\.webgl)?$/u.test(e)}a(_,"validParityScene");function re(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))}a(re,"validParityTimestamp");function Y(e){if(!a$1(e))throw new Error("Shader parity evidence is invalid.");if(e.schemaVersion===1){if(typeof e.receiptHash!="string"||!/^[a-f0-9]{64}$/u.test(e.receiptHash)||!re(e.verifiedAt)||!Array.isArray(e.scenes)||e.scenes.length===0||e.scenes.length>64||!e.scenes.every(t=>typeof t=="string"&&_(t)))throw new Error("Shader parity evidence is invalid.");return {schemaVersion:1,receiptHash:e.receiptHash,verifiedAt:e.verifiedAt,scenes:[...new Set(e.scenes)].sort()}}if(e.schemaVersion!==2||!a$1(e.scenes))throw new Error("Shader parity evidence is invalid.");let r=Object.entries(e.scenes);if(r.length===0||r.length>64)throw new Error("Shader parity evidence is invalid.");let n={};for(let[t,i]of r.sort(([s],[o])=>s.localeCompare(o))){if(!_(t)||!a$1(i)||typeof i.fingerprint!="string"||!/^[a-f0-9]{64}$/u.test(i.fingerprint)||!re(i.verifiedAt))throw new Error("Shader parity evidence is invalid.");n[t]={fingerprint:i.fingerprint,verifiedAt:i.verifiedAt};}return {schemaVersion:2,scenes:n}}a(Y,"parseShaderParityEvidence");function G(e,r){let n=e.scenes[r];if(n===void 0)throw new Error(`Shader receipt has no scene "${r}" for parity evidence.`);return c(E({runtime:{three:e.runtime.three,threeBlocks:e.runtime.threeBlocks,threeBlocksShaderClosure:e.runtime.threeBlocksShaderClosure},...e.tool===void 0?{}:{tool:e.tool},scene:n}))}a(G,"shaderSceneParityFingerprint");async function te(e,r,n,t){let i=d.join(e,n);try{if(!await d$1(i))return;let s=await lstat(i);if(s.isSymbolicLink()||!s.isFile()||s.size>1024*1024)return;let o=U(JSON.parse(await readFile(i,"utf8")));return o.source===t&&o.receiptHash===c(r)?o:void 0}catch{return}}a(te,"readShaderTimingFile");async function De(e,r){return await te(e,r,de,"latest-local-capture")??await te(e,r,ce,"committed-capture")}a(De,"readShaderTiming");async function ue(e,r){let n=d.join(e,q);try{if(!await d$1(n))return;let t=await lstat(n);if(t.isSymbolicLink()||!t.isFile()||t.size>1024*1024)return;let i=Y(JSON.parse(await readFile(n,"utf8"))),s=c$1(JSON.parse(Buffer.from(r).toString("utf8"))),o={};if(i.schemaVersion===1){if(i.receiptHash!==c(r))return;for(let u of i.scenes)s.scenes[u]!==void 0&&(o[u]={fingerprint:G(s,u),verifiedAt:i.verifiedAt});}else for(let[u,l]of Object.entries(i.scenes))s.scenes[u]===void 0||l.fingerprint!==G(s,u)||(o[u]=l);return Object.keys(o).length===0?void 0:{schemaVersion:2,scenes:o}}catch{return}}a(ue,"readShaderParityEvidence");async function pe(e,r,n){let t=await x(e),i=d.join(t,"meta.json"),s=await lstat(i);if(s.isSymbolicLink()||!s.isFile())throw new Error("Shader receipt must be a regular file before timing.");let o=await readFile(i),u=new Date().toISOString(),l=Object.fromEntries(Object.entries(r).sort(([R],[S])=>R.localeCompare(S))),g=U({schemaVersion:3,receiptHash:c(o),measuredAt:u,source:"latest-local-capture",scenes:l});if(await f(d.join(t,de),`${E(g)}
|
|
12
|
-
`),n===void 0)return {local:g};let m=U({schemaVersion:3,receiptHash:c(o),measuredAt:u,source:"committed-capture",adapter:n.adapter,platform:n.platform,scenes:l});return await f(d.join(t,ce),`${E(m)}
|
|
13
|
-
`),{local:g,committed:m}}a(pe,"writeShaderTimings");async function Ne(e,r){return (await pe(e,r)).local}a(Ne,"writeShaderLocalTiming");async function ve(e,r,n){if(r.length===0||r.length>64||r.some(S=>!_(S)))throw new Error("Shader parity evidence must contain 1...64 valid scene keys.");let t=await x(e),i=d.join(t,"meta.json"),s=await lstat(i);if(s.isSymbolicLink()||!s.isFile())throw new Error("Shader receipt must be a regular file before parity evidence.");let o=await readFile(i);if(n!==void 0&&c(o)!==c(n))throw new Error("Shader receipt changed during browser parity verification; completed observations were not attached to the new receipt.");let u=c$1(JSON.parse(o.toString("utf8"))),l=await ue(t,o),g=new Date().toISOString(),m={...l?.scenes};for(let S of [...new Set(r)].sort())m[S]={fingerprint:G(u,S),verifiedAt:g};let R=Y({schemaVersion:2,scenes:m});return await f(d.join(t,q),`${E(R)}
|
|
14
|
-
`),R}a(ve,"writeShaderParityEvidence");async function Fe(e,r,n){if(r.length===0||r.length>64||r.some(m=>!_(m)))throw new Error("Shader parity invalidation must contain 1...64 valid scene keys.");let t=await x(e),i=await readFile(d.join(t,"meta.json"));if(c(i)!==c(n))throw new Error("Shader receipt changed before prior parity evidence could be invalidated.");let s=await ue(t,i);if(s===void 0)return;let o=new Set(r),u=Object.fromEntries(Object.entries(s.scenes).filter(([m])=>!o.has(m))),l=d.join(t,q);if(Object.keys(u).length===0){await unlink(l).catch(m=>{if(!a$1(m)||m.code!=="ENOENT")throw m});return}let g=Y({schemaVersion:2,scenes:u});await f(l,`${E(g)}
|
|
15
|
-
`);}a(Fe,"removeShaderParityEvidence");async function We(e,r,n){let t=await pe(e,r,n);if(t.committed===void 0)throw new Error("Committed shader timing was not written.");return {local:t.local,committed:t.committed}}a(We,"writeShaderTimingTwins");async function ne(e){if(!await d$1(e)){await mkdir(e);return}let r=await lstat(e);if(r.isSymbolicLink()||!r.isDirectory())throw new Error(`Shader artifact path is not a real directory: ${e}.`)}a(ne,"assertDirectory");async function x(e){let r=d.resolve(e),n=d.join(r,".three-blocks");await ne(n);let t=d.join(n,"shaders");return await ne(t),t}a(x,"artifactRoot");async function Ue(e$2){let r=await x(e$2.root),n=e$2.backends??["webgpu"],t=Object.fromEntries(n.map(a=>[a,v(e$2.runtime.three,a)])),i$1=d.resolve(e$2.root),s=d.resolve(i$1,e$2.publicDirectory??"public");if(!e(i$1,s)||s===i$1)throw new Error("Shader public directory must stay inside the project root.");let o=d.join(s,"three-blocks","shaders");await mkdir(o,{recursive:true}),await i(i$1,o,"Shader static-asset directory");let u={},l=[];for(let a of [...e$2.scenes].sort((b,k)=>b.key.localeCompare(k.key))){let b=e$2.inputs.get(a.key);if(b===void 0)throw new Error(`Shader input matrix is missing scene "${a.key}".`);for(let k of e$1(a,n)){let T=g(a.key,k),M=e$2.captures.get(T);if(M===void 0){let f=e$2.previousReceipt?.scenes[T];if(f===void 0)continue;let V=await readFile(d.join(r,f.artifact));if(c(V)!==f.artifactHash)throw new Error(`Preserved shader artifact checksum differs for "${T}".`);if(f.asset!==void 0&&f.assetHash!==void 0){let L=await readFile(d.join(s,f.asset));if(c(L)!==f.assetHash)throw new Error(`Preserved static shader manifest checksum differs for "${T}".`)}u[T]={...f,backend:k,inputs:Object.fromEntries(Object.entries(b).sort(([L],[me])=>L.localeCompare(me)))},l.push(f.artifact),f.asset!==void 0&&l.push(d.relative(i$1,d.join(s,f.asset)).split(d.sep).join("/"));continue}if(M.scene!==a.key||M.backend!==k||M.manifest.scene!==a.key)throw new Error(`Capture matrix scene/backend "${T}" is inconsistent.`);let I=`${a.key}.${k}.ts`,$=Be(M.manifest);await f(d.join(r,I),$),l.push(I);let H=`three-blocks/shaders/${a.key}.${k}.json`,J=`${E(M.manifest)}
|
|
16
|
-
`;await f(d.join(s,H),J),l.push(d.relative(i$1,d.join(s,H)).split(d.sep).join("/"));let z=M.skipped.filter(f=>f.kind==="render").length,le=M.skipped.length-z;u[T]={backend:k,artifact:I,artifactHash:c($),asset:H,assetHash:c(J),inputs:Object.fromEntries(Object.entries(b).sort(([f],[V])=>f.localeCompare(V))),coverage:M.coverage,bytes:Buffer.byteLength($),skipped:{render:z,compute:le}};}}let g$1=[...e$2.captures.values()].find(a=>a.provenance!==void 0)?.provenance??e$2.previousReceipt?.runtime.capture,m={schemaVersion:2,runtime:{...e$2.runtime,...g$1===void 0?{}:{capture:g$1}},tool:{name:"@three-blocks/devtools",version:a$2,compatibility:t[n[0]??"webgpu"],compatibilities:t,transform:be,address:SHADER_ADDRESS_SCHEMA_VERSION,recipe:SHADER_RECIPE_SCHEMA_VERSION,hydration:SHADER_HYDRATION_SCHEMA_VERSION},scenes:u},R=new Set(l);for(let a of await readdir(r,{withFileTypes:true}))if(!(!/\.(?:webgpu|webgl)\.ts$/u.test(a.name)||R.has(a.name))){if(a.isSymbolicLink()||!a.isFile())throw new Error(`Orphan shader artifact is not a regular file: ${a.name}.`);await unlink(d.join(r,a.name));}let S=new Set(e$2.scenes.flatMap(a=>e$1(a,n).map(b=>`${a.key}.${b}.json`))),w=new Set(Object.values(e$2.previousReceipt?.scenes??{}).map(a=>a.asset===void 0?void 0:d.posix.basename(a.asset)).filter(a=>a!==void 0));try{let a=c$1(JSON.parse(await readFile(d.join(r,"meta.json"),"utf8")));for(let b of Object.values(a.scenes))b.asset!==void 0&&w.add(d.posix.basename(b.asset));}catch{}for(let a of await readdir(o,{withFileTypes:true}))if(!(!a.name.endsWith(".json")||S.has(a.name))&&w.has(a.name)){if(a.isSymbolicLink()||!a.isFile())throw new Error(`Orphan shader static asset is not a regular file: ${a.name}.`);await unlink(d.join(o,a.name));}return await f(d.join(r,"meta.json"),`${E(m)}
|
|
17
|
-
`),l.push("meta.json"),{directory:r,receipt:m,files:l}}a(Ue,"writeShaderArtifacts");export{v as a,be as b,Le as c,E as d,De as e,Ne as f,ve as g,Fe as h,We as i,Ue as j};
|
package/dist/chunk-EI7MMDWY.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var c=Object.defineProperty;var d=(a,b)=>c(a,"name",{value:b,configurable:true});export{d as a};
|
package/dist/chunk-HOZDD6PW.js
DELETED
package/dist/chunk-LKXY5YU2.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {b,e as e$2,a as a$4,d as d$2,c as c$2,j as j$2,i as i$2,f as f$2,h as h$1,g as g$1}from'./chunk-7N6TU4JG.js';import {a as a$3}from'./chunk-ZT6T2W4B.js';import {i,j as j$1,d as d$1,e as e$1,g,b as b$1,l,f as f$1,k as k$1,c as c$3}from'./chunk-NPLE7PPF.js';import {a as a$2,c as c$1}from'./chunk-65VEJRRT.js';import {j,a as a$1,c,d,k,h,e,i as i$1,f}from'./chunk-5L2VS3BN.js';import {a}from'./chunk-HOZDD6PW.js';import {realpath,readdir,readFile,lstat,mkdir,writeFile}from'fs/promises';import Ae from'os';import L from'path';import {SHADER_ADDRESS_SCHEMA_VERSION,SHADER_RECIPE_SCHEMA_VERSION,SHADER_HYDRATION_SCHEMA_VERSION}from'three-blocks/shaders';import {createRequire}from'module';var Ge=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".wgsl",".glsl",".vert",".frag",".json",".css"],Je=new Set(Ge),qe=/^(?:three-blocks\.shaders\.json|(?:precompile|three-blocks\.shaders)\.config\.(?:cjs|cts|js|mjs|mts|ts))$/u,Cr=/(?:^|\/)scene\.(?:cjs|cts|js|jsx|mjs|mts|ts|tsx)$/u,jr=/\b(?:export\s+)?(?:async\s+)?function\s+createScene\b|\bcreateScene\s*=\s*(?:async\s*)?\(/u,Dr=/\b(?:[A-Za-z_$][\w$]*\.)*(?:shaders|shaderCache|sceneShaders)\s*\.\s*(?:material|pipeline|compute|container)\s*\(/u,Ar=/\b(import|export)(?!\s*\()\s*(type\b\s*)?(?:[^"'();]*?\bfrom\s*)?["']([^"']+)["']/gu,_r=/\bimport\s*\(\s*["']([^"']+)["']\s*\)/gu,Fr=/\b(?:import|export)(?!\s*\()\s*(?:[^"'();]*?\bfrom\s*)?["']([^"']+)["']|\bimport\s*\(\s*["']([^"']+)["']\s*\)/gu,Nr=/^[0-9A-Za-z][0-9A-Za-z.+_-]{0,127}$/u,Ye=4096,Lr="./shaders";function mr(e,r){let n=L.relative(e,r).split(L.sep).join("/");if(n.length===0||/[\u0000-\u001f\u007f]/u.test(n))throw new Error("Semantic input has an unsafe relative path.");return n}a(mr,"portableRelativePath");function Xe(e,r){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{throw new Error(`Shader-relevant source ${JSON.stringify(r)} is not valid UTF-8.`)}}a(Xe,"sourceText");function Qe(e,r){let n="",t="code";for(let i=0;i<e.length;i++){let s=e[i]??"",c=e[i+1]??"";if(t==="code"){if(s==="/"&&c==="/"){n+=" ",t="line-comment",i++;continue}if(s==="/"&&c==="*"){n+=" ",t="block-comment",i++;continue}if(s==="'"||s==='"'||s==="`"){t=s==="'"?"single":s==='"'?"double":"template",n+=r?s:" ";continue}n+=s;continue}if(t==="line-comment"){s===`
|
|
3
|
-
`?(n+=`
|
|
4
|
-
`,t="code"):n+=" ";continue}if(t==="block-comment"){s==="*"&&c==="/"?(n+=" ",t="code",i++):n+=s===`
|
|
5
|
-
`?`
|
|
6
|
-
`:" ";continue}let o=t==="single"?"'":t==="double"?'"':"`";if(s==="\\"&&c.length>0){n+=r?`${s}${c}`:" ",i++;continue}n+=r?s:s===`
|
|
7
|
-
`?`
|
|
8
|
-
`:" ",s===o&&(t="code");}return n}a(Qe,"lexicalSource");function Vr(e){let r=new Set,n=Qe(e,true);for(let t of n.matchAll(Ar))t[2]===void 0&&t[3]!==void 0&&r.add(t[3]);for(let t of n.matchAll(_r))t[1]!==void 0&&r.add(t[1]);return [...r].sort()}a(Vr,"importSpecifiers");function Hr(e){let r=new Set;for(let n of Qe(e,true).matchAll(Fr)){let t=n[1]??n[2];t!==void 0&&r.add(t);}return [...r].sort()}a(Hr,"runtimeSpecifiers");function pr(e){return (e.split(/[?#]/u,1)[0]??e).replaceAll("\\","/")}a(pr,"cleanSpecifier");function Wr(e,r,n){let t=pr(r),i;if(t.startsWith("./")||t.startsWith("../"))i=L.posix.normalize(L.posix.join(L.posix.dirname(e),t));else if(t.startsWith("@/"))i=`src/${t.slice(2)}`;else if(t.startsWith("/src/"))i=t.slice(1);else return;if(i===".three-blocks"||i.startsWith(".three-blocks/"))return;let s=L.posix.extname(i).toLowerCase(),c=new Set([i]);if(s.length===0||!Je.has(s)){for(let o of Ge)c.add(`${i}${o}`);for(let o of Ge)c.add(`${i}/index${o}`);}else if([".js",".mjs",".cjs",".jsx"].includes(s)){let o=i.slice(0,-s.length);for(let m of [".ts",".tsx",".mts",".cts"])c.add(`${o}${m}`);}return [...c].find(o=>n.has(o))}a(Wr,"resolveProjectImport");function Kr(e,r){let n=Qe(r,false);return Cr.test(e)||jr.test(n)||Dr.test(n)}a(Kr,"isShaderRoot");async function Ce(e,r){let n=await realpath(e);if(r!==void 0){let a={},u=0;for(let w of r){let O=await j(n,L.join(n,w),a$1.semanticInput,"Declared shader semantic input");if(u+=O.data.byteLength,u>a$1.semanticTotal)throw new Error("Declared shader semantic inputs exceed the total inspection size limit.");a[w]=c(O.data);}return a}let t=new Map,i=L.join(n,"src");if(await d(i))for(let a of await k(n,i,u=>Je.has(L.extname(u).toLowerCase()))){let u=await j(n,a,a$1.semanticInput,"Shader semantic input");t.set(mr(n,a),u.data);}for(let a of await readdir(n,{withFileTypes:true})){if(!a.isFile()||!qe.test(a.name)&&!Je.has(L.extname(a.name).toLowerCase()))continue;let u=await j(n,L.join(n,a.name),a$1.semanticInput,qe.test(a.name)?"Shader configuration input":"Shader semantic input");t.set(a.name,u.data);}if(t.size>Ye)throw new Error(`Shader input discovery exceeds the ${Ye}-file limit.`);let s=new Set,c$1=new Map;for(let[a,u]of t){if(!a.includes("/")&&qe.test(a)&&s.add(a),!a.startsWith("src/"))continue;let w=Xe(u,a);c$1.set(a,w),Kr(a,w)&&s.add(a);}if(s.size===0)throw new Error("No shader registration or scene source root was found.");let o=new Set,m=[...s].sort();for(;m.length>0;){let a=m.shift();if(a===void 0||o.has(a))continue;let u=t.get(a);if(u===void 0)continue;o.add(a);let w=c$1.get(a)??Xe(u,a);for(let O of Vr(w)){let V=Wr(a,O,t);V!==void 0&&!o.has(V)&&m.push(V);}m.sort();}let l=0,f={};for(let a of [...o].sort()){let u=t.get(a);if(u===void 0)throw new Error(`Shader input ${JSON.stringify(a)} disappeared during inspection.`);if(l+=u.byteLength,l>a$1.semanticTotal)throw new Error("Semantic shader inputs exceed the total inspection size limit.");f[a]=c(u);}return f}a(Ce,"snapshotShaderInputs");function Ze(e){if(typeof e=="string")return e;if(a$2(e))return Ze(e.import)??Ze(e.default)}a(Ze,"conditionalImportTarget");async function fr(e,r){let n=e;for(;;){let t=L.join(n,"node_modules",...r.split("/"),"package.json");if(await d(t)){let s=await h(t,a$1.packageJson,`${r} package.json`),c=JSON.parse(s.data.toString("utf8"));if(!a$2(c)||c.name!==r||typeof c.version!="string"||!Nr.test(c.version))throw new Error(`Installed ${r} package metadata is invalid.`);return {root:L.dirname(s.path),manifest:c}}let i=L.dirname(n);if(i===n)break;n=i;}throw new Error(`Cannot verify the installed ${r} package.`)}a(fr,"findInstalledPackage");async function zr(e$1,r){if(!a$2(r.exports))throw new Error("Installed three-blocks package has no public exports map.");let n=Ze(r.exports[Lr]);if(n===void 0||!n.startsWith("./"))throw new Error("Installed three-blocks shader export has no import target.");let t=await realpath(e$1),i=[L.resolve(t,n)],s=new Map,c$1=0;for(;i.length>0;){let m=i.shift();if(m===void 0)break;let l=await h(m,a$1.semanticInput,"Three Blocks shader runtime module");if(!e(t,l.path)||l.path===t)throw new Error("Three Blocks shader runtime closure escapes its package.");let f=mr(t,l.path);if(s.has(f))continue;if(c$1+=l.data.byteLength,c$1>a$1.semanticTotal)throw new Error("Three Blocks shader runtime closure exceeds the inspection limit.");s.set(f,c(l.data));let a=Xe(l.data,f);for(let u of Hr(a)){let w=pr(u);if(!w.startsWith("./")&&!w.startsWith("../"))continue;let O=L.resolve(L.dirname(l.path),w);if(!e(t,O))throw new Error("Three Blocks shader runtime import escapes its package.");i.push(O);}if(i.sort(),s.size+i.length>Ye)throw new Error("Three Blocks shader runtime closure exceeds the file limit.")}let o=[...s].sort((m,l)=>m[0].localeCompare(l[0])).map(([m,l])=>`${m}\0${l}`).join(`
|
|
9
|
-
`);return c(o)}a(zr,"shaderRuntimeClosure");async function we(e){let[r,n]=await Promise.all([fr(e,"three"),fr(e,"three-blocks")]);return {three:String(r.manifest.version),threeBlocks:String(n.manifest.version),threeBlocksShaderClosure:await zr(n.root,n.manifest)}}a(we,"readInstalledShaderRuntime");var Sr=4096,qr=createRequire(import.meta.url),gr,E=new Proxy({},{get(e,r){return gr??=qr("typescript"),Reflect.get(gr,r)}});function te(e){let r=e;for(;E.isParenthesizedExpression(r)||E.isAsExpression(r)||E.isSatisfiesExpression(r)||E.isNonNullExpression(r);)r=r.expression;return r}a(te,"unwrap");function Gr(e){if(E.isIdentifier(e)||E.isStringLiteral(e)||E.isNumericLiteral(e))return e.text}a(Gr,"propertyName");function ve(e,r){let n=new Map;for(let t of e.properties){if(!E.isPropertyAssignment(t))throw new Error(`${r} may contain only static property assignments.`);let i=Gr(t.name);if(i===void 0||n.has(i))throw new Error(`${r} contains a computed or duplicate property.`);n.set(i,t.initializer);}return n}a(ve,"properties");function be(e,r){if(e===void 0)throw new Error(`${r} is missing.`);let n=te(e);if(!E.isObjectLiteralExpression(n))throw new Error(`${r} must be a static object literal.`);return n}a(be,"objectLiteral");function ke(e,r){if(e===void 0)throw new Error(`${r} is missing.`);let n=te(e);if(!E.isStringLiteral(n)&&!E.isNoSubstitutionTemplateLiteral(n))throw new Error(`${r} must be a string literal.`);return n.text}a(ke,"stringLiteral");function je(e,r){if(e===void 0)throw new Error(`${r} is missing.`);let n=te(e);if(!E.isNumericLiteral(n))throw new Error(`${r} must be a numeric literal.`);return Number(n.text)}a(je,"numericLiteral");function yr(e,r){if(e===void 0)throw new Error(`${r} is missing.`);let n=te(e);if(!E.isArrayLiteralExpression(n))throw new Error(`${r} must be a static array literal.`);return n.elements}a(yr,"arrayLiteral");function Jr(e,r){if(e===void 0)throw new Error(`${r} is missing.`);let n=te(e);if(n.kind===E.SyntaxKind.NullKeyword)return null;if(!E.isNumericLiteral(n))throw new Error(`${r} must be null or a numeric literal.`);return Number(n.text)}a(Jr,"numericOrNullLiteral");function Yr(e){return e.parseDiagnostics??[]}a(Yr,"parseDiagnostics");function wr(e,r,n,t){let i=E.createSourceFile(r,e,E.ScriptTarget.Latest,true,E.ScriptKind.TS),s=Yr(i);if(s.length>0)throw new Error(`Shader manifest is not valid TypeScript: ${E.flattenDiagnosticMessageText(s[0]?.messageText??"parse error"," ")}`);let c=i.statements.filter(E.isExportAssignment).filter(v=>!v.isExportEquals);if(c.length!==1)throw new Error("Shader manifest must contain exactly one default export.");let o=ve(be(c[0]?.expression,"Shader manifest default export"),"Shader manifest"),m=o.get("version");if(m===void 0||!E.isNumericLiteral(te(m))||Number(te(m).getText(i))!==3)throw new Error("Shader manifest version must be the numeric literal 3.");if(ke(o.get("scene"),"Shader manifest scene")!==n)throw new Error(`Shader manifest scene does not match "${n}".`);let l=o.get("runtime"),a$1=(t?.compatibility??(l===void 0?"":ke(ve(be(l,"Shader manifest runtime"),"Shader manifest runtime").get("id"),"Shader manifest runtime id"))).startsWith("three-webgl-");if(t){if(ke(o.get("three"),"Shader manifest Three.js version")!==t.three||ke(o.get("threeBlocks"),"Shader manifest Three Blocks version")!==t.threeBlocks)throw new Error("Shader manifest runtime versions do not match its receipt.");let v=ve(be(o.get("runtime"),"Shader manifest runtime"),"Shader manifest runtime");if(ke(v.get("id"),"Shader manifest runtime id")!==t.compatibility||je(v.get("address"),"Shader manifest address schema")!==t.address||je(v.get("recipe"),"Shader manifest recipe schema")!==t.recipe||je(v.get("hydration"),"Shader manifest hydration schema")!==t.hydration)throw new Error("Shader manifest runtime compatibility schemas do not match its receipt.")}let u=ve(be(o.get("entries"),"Shader manifest entries"),"Shader manifest entries");if(u.size===0&&!a$1||u.size>Sr)throw new Error(`Shader manifest must contain ${a$1?"0":"1"}...${Sr} entries.`);let w=yr(o.get("modules"),"Shader manifest modules").map((v,$)=>{let D=te(v);if(!E.isStringLiteral(D)&&!E.isNoSubstitutionTemplateLiteral(D))throw new Error(`Shader manifest module ${$} must be a shader string literal.`);if(D.text.length===0)throw new Error(`Shader manifest module ${$} is empty.`);return D.text}),O=yr(o.get("states"),"Shader manifest states").map((v,$)=>{let D=ve(be(v,`Shader manifest state ${$}`),`Shader manifest state ${$}`),T=a((q,p)=>{let b=Jr(D.get(q),`Shader manifest state ${$} ${q}`);if(b===null)return false;let x=w[b];if(x===void 0||!a$1&&!x.includes(p))throw new Error(`Shader manifest state ${$} ${q} does not reference a ${p} module.`);return true},"moduleAt"),A=T("vertex","@vertex"),C=T("fragment","@fragment"),H=T("compute","@compute");if(H&&(A||C))throw new Error(`Shader manifest state ${$} mixes render and compute stages.`);if(!H&&!A&&!C)throw new Error(`Shader manifest state ${$} contains no shader stage.`);return {vertex:A,fragment:C,compute:H}}),V={render:0,vertex:0,fragment:0,compute:0};for(let[v,$]of u){if(v.length===0||/[\u0000-\u001f\u007f]/.test(v))throw new Error("Shader manifest contains an invalid entry key.");let D=je($,`Shader manifest entry "${v}"`),T=O[D];if(T===void 0)throw new Error(`Shader manifest entry "${v}" references an absent state.`);(T.vertex||T.fragment)&&(V.render+=1),T.vertex&&(V.vertex+=1),T.fragment&&(V.fragment+=1),T.compute&&(V.compute+=1);}return V}a(wr,"inspectPrecompiledManifest");function Xr(e,r){return e.render===r.render&&e.vertex===r.vertex&&e.fragment===r.fragment&&e.compute===r.compute}a(Xr,"sameCoverage");function Zr(e){let r=e.some(t=>t.state==="invalid")?"invalid":e.some(t=>t.state==="missing")?"missing":e.some(t=>t.state==="stale")?"stale":"fresh",n=e.filter(t=>t.state===r);return {state:r,reason:r==="fresh"?`${e.length} configured shader scene${e.length===1?" is":"s are"} fresh.`:n.map(t=>`${t.scene} (${t.backend}): ${t.reason}`).join("; ")}}a(Zr,"classifyMatrix");function Qr(e,r,n){let t=e.tool;if(!t)return "Shader receipt has no public tool compatibility metadata.";if((t.compatibilities?.[n]??t.compatibility)!==r)return "Shader receipt targets a different runtime compatibility contract.";if(t.transform!==b)return "Shader receipt uses a different provider transform version.";if(t.address!==SHADER_ADDRESS_SCHEMA_VERSION||t.recipe!==SHADER_RECIPE_SCHEMA_VERSION||t.hydration!==SHADER_HYDRATION_SCHEMA_VERSION)return "Shader receipt uses incompatible address, recipe, or hydration schemas."}a(Qr,"exactToolCompatibility");function et(e,r){let n=Object.keys(r).filter(s=>Object.hasOwn(e,s)&&e[s]!==r[s]),t=Object.keys(r).filter(s=>!Object.hasOwn(e,s)),i=Object.keys(e).filter(s=>!Object.hasOwn(r,s));return {...n.length>0?{changedInputs:n}:{},...t.length>0?{addedInputs:t}:{},...i.length>0?{removedInputs:i}:{}}}a(et,"inputChanges");async function De(e=process.cwd(),r,n){let t=await i(e),i$2=await j$1(t),s=d$1(n??i$2.backend),c$2=i$2.scenes.flatMap(l=>e$1(l,s).map(f=>({scene:l,backend:f,key:g(l.key,f)}))),o=L.join(t,b$1),m=a(()=>({schemaVersion:1,root:t,state:"missing",reason:`${b$1}/meta.json is absent.`,scenes:c$2.map(({scene:l,backend:f})=>({scene:l.key,backend:f,state:"missing",reason:"No committed shader receipt."}))}),"missing");if(!await d(o)||!await d(L.join(o,"meta.json")))return m();try{let l=await i$1(t,o,"Shader artifact directory"),f=await j(l,L.join(l,"meta.json"),a$1.receipt,"Shader receipt"),a=c$1(JSON.parse(f.data.toString("utf8"))),u=await e$2(l,f.data),w=r??await we(t),O=new Set(i$2.scenes.flatMap(p=>e$1(p,["webgpu","webgl"]).map(b=>g(p.key,b)))),v=Object.keys(a.scenes).filter(p=>!O.has(p));if(v.length>0)throw new Error(`Shader receipt contains unconfigured scenes: ${v.join(", ")}.`);let $=a.runtime.three!==w.three,D=a.runtime.threeBlocksShaderClosure!==w.threeBlocksShaderClosure,T=a.tool?.version!==a$3,A=L.join(t,i$2.publicDir??"public"),C=[];for(let{scene:p,backend:b,key:x}of c$2){let h=a.scenes[x];if(!h){C.push({scene:p.key,backend:b,state:"missing",reason:"Scene/backend is absent from the complete receipt matrix."});continue}let _=a$4(w.three,b),j$1=Qr(a,_,b);if(j$1)throw new Error(`${x}: ${j$1}`);let K=await j(l,L.join(l,h.artifact),a$1.manifest,"Shader manifest");if(c(K.data)!==h.artifactHash)throw new Error(`Shader artifact checksum differs for scene "${p.key}".`);if(h.asset!==void 0&&h.assetHash!==void 0){let F=await j(A,L.join(A,h.asset),a$1.manifest,"Static shader manifest");if(c(F.data)!==h.assetHash)throw new Error(`Static shader manifest checksum differs for scene "${p.key}".`)}if(h.bytes!==void 0&&h.bytes!==K.data.byteLength)throw new Error(`Shader artifact byte count differs for scene "${p.key}".`);let B=wr(K.data.toString("utf8"),K.path,p.key,{three:a.runtime.three,threeBlocks:a.runtime.threeBlocks,compatibility:_,address:SHADER_ADDRESS_SCHEMA_VERSION,recipe:SHADER_RECIPE_SCHEMA_VERSION,hydration:SHADER_HYDRATION_SCHEMA_VERSION});if(!Xr(B,h.coverage))throw new Error(`Shader coverage differs for scene "${p.key}".`);if(b==="webgpu"&&!i$2.allowLiveBuilds&&h.skipped&&h.skipped.render+h.skipped.compute>0)throw new Error(`Scene "${p.key}" contains skipped live builds but allowLiveBuilds is false.`);let S=await Ce(t,p.inputs),k=et(h.inputs,S),y=(k.changedInputs?.length??0)+(k.addedInputs?.length??0)+(k.removedInputs?.length??0),g=$||D||T||y>0,M=u?.scenes[x],R=M===void 0||u===void 0?void 0:{...M,schemaVersion:u.schemaVersion,measuredAt:u.measuredAt,source:u.source,...u.source==="committed-capture"?{adapter:u.adapter,platform:u.platform}:{}};C.push({scene:p.key,backend:b,state:g?"stale":"fresh",reason:$?"Installed Three.js version differs from the receipt.":D?"Installed three-blocks/shaders runtime closure differs from the receipt.":T?`Receipt was generated by @three-blocks/devtools ${a.tool?.version??"unknown"}.`:y>0?`${y} semantic shader input${y===1?"":"s"} changed.`:"Manifest, runtime, schemas, transform, and semantic inputs match.",coverage:B,...!g&&R!==void 0&&R.builds===B.render+B.compute?{timing:R}:{},...k});}let H=Zr(C),q=H.state==="fresh"&&u!==void 0&&C.every(p=>p.timing!==void 0)?u:void 0;return {schemaVersion:1,root:t,...H,scenes:C,runtime:w,receipt:a,...q===void 0?{}:{timing:q}}}catch(l){let f=l instanceof Error?l.message:String(l);return {schemaVersion:1,root:t,state:"invalid",reason:f,scenes:c$2.map(({scene:a,backend:u})=>({scene:a.key,backend:u,state:"invalid",reason:f}))}}}a(De,"inspectShaderMatrix");var xr=".three-blocks/shaders/pending-capture";function nt(e){return (e instanceof Error?`${e.name}: ${e.message}`:String(e)).includes("ShaderHydrationError:")}a(nt,"isShaderHydrationFailure");async function it(e,r,n){if(r.length===0)return;let t=L.join(e,b$1,"meta.json"),i=await readFile(t);if(c(i)!==c(n))throw new Error("Shader receipt changed before failed scenes could be marked for recapture.");let s=c$1(JSON.parse(i.toString("utf8"))),c$2=c(n),o=new Set(r),m=c$1({...s,scenes:Object.fromEntries(Object.entries(s.scenes).map(([l,f])=>[l,o.has(l)?{...f,inputs:{...f.inputs,[xr]:c$2}}:f]))});await f(t,`${d$2(m)}
|
|
10
|
-
`);}a(it,"markShaderScenesForRecapture");function st(e,r){return d$2(e)===d$2(r)}a(st,"equalSnapshot");async function Vt(e={}){let r=e.root?await realpath(e.root):await i(e.start),n=e.config===void 0?await l(r):void 0,t=e.config??n?.config??await j$1(r),i$1=e.runtime??await we(r),s=d$1(e.backend??t.backend),c$1=d$1(t.backend),o=[...new Set([...c$1,...s])],m=[...s].reverse(),l$1=[...f$1(t.scenes,m)],f,a$1={},u;if(e.ifStale){let S=await De(r,i$1,e.backend??t.backend);if(S.state==="fresh"&&S.scenes.every(k=>k.timing!==void 0))return {schemaVersion:1,root:r,skipped:true,reason:S.reason,scenes:[]};if(S.state!=="invalid"&&S.receipt!==void 0){let k=S.state==="fresh";l$1=l$1.filter(({scene:y,backend:g})=>{let M=S.scenes.find(R=>R.scene===y.key&&R.backend===g);return M?.state!=="fresh"||k&&M.timing===void 0}),f=S.receipt;for(let y of S.scenes){if(y.state!=="fresh"||y.timing===void 0)continue;let{builds:g$1,liveBuildMs:M,precompiledBuildMs:R,avoidedBuildMs:F,runs:W,spreadMs:Ee}=y.timing;a$1[g(y.scene,y.backend)]={builds:g$1,liveBuildMs:M,precompiledBuildMs:R,avoidedBuildMs:F,runs:W,spreadMs:Ee},y.timing.source==="committed-capture"&&y.timing.adapter!==void 0&&y.timing.platform!==void 0&&(u={adapter:y.timing.adapter,platform:y.timing.platform});}}}let w=performance.now(),O=f!==void 0&&(f.runtime.three!==i$1.three||f.runtime.threeBlocksShaderClosure!==i$1.threeBlocksShaderClosure||f.tool?.version!==a$3)?c(d$2({runtime:f.runtime,tool:f.tool})):void 0,V=a(async()=>new Map(await Promise.all(t.scenes.map(async S=>[S.key,await Ce(r,S.inputs)]))),"snapshotInputs"),v=await V(),$=a(async()=>{let S=await V();for(let k of t.scenes){let y=v.get(k.key),g=S.get(k.key);if(y===void 0||g===void 0||!st(y,g))throw new Error(`Semantic shader inputs changed during capture for scene "${k.key}"; the current scene was not committed.`)}},"assertInputsUnchanged"),D=e.driver===void 0,T=e.driver===void 0&&e.driverKind===void 0&&e.serve===void 0&&e.url===void 0?await k$1(r):void 0,A=e.serve??T?.serve,C=e.driverKind??T?.driverKind??(A===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(C==="vite"&&A!==void 0)throw new Error("--serve requires the static shader driver.");if(C==="static"&&A===void 0&&e.driver===void 0)throw new Error("The static shader driver requires --serve <built-directory>.");let H=e.driver===void 0?await import('./shader-browser-H5CB2ZQX.js'):void 0,q=a(()=>e.url!==void 0?H.createAttachedPlaywrightShaderDriver({root:r,runtime:i$1,url:e.url,...e.headed!==void 0?{headed:e.headed}:{}}):C==="static"?H.createStaticPlaywrightShaderDriver({root:r,runtime:i$1,serve:A,...e.headed!==void 0?{headed:e.headed}:{}}):H.createPlaywrightShaderDriver({root:r,runtime:i$1,...e.headed!==void 0?{headed:e.headed}:{}}),"createDriver"),p=new Map,b=a(S=>{if(e.driver!==void 0)return e.driver;let k=p.get(S);return k===void 0&&(k=q(),p.set(S,k)),k},"driverFor"),x=new Map,h=[],_=f!==void 0&&t.scenes.every(S=>e$1(S,o).every(k=>f?.scenes[g(S.key,k)]!==void 0)),j=f,K,B=e.attempts??2;if(!Number.isSafeInteger(B)||B<1||B>5)throw new Error("Shader capture attempts must be an integer in 1...5.");try{for(let[g$1,M]of l$1.entries()){let{scene:R,backend:F,key:W}=M,Ee=b(F);e.onSceneStart?.(W,g$1,l$1.length);let N,Se,se=0;for(;se<B;se++)try{N=c$2(await Ee.capture(R,t,F),{scene:R.key,backend:F,runtime:i$1});let Q=F==="webgl"&&N.skipped.every(G=>G.reason.startsWith("WebGL shader precompilation does not support "));if(N.skipped.length>0&&!t.allowLiveBuilds&&!Q)throw new Error(`Scene "${R.key}" contains ${N.skipped.length} unregistered live shader build${N.skipped.length===1?"":"s"} while allowLiveBuilds is false.`);break}catch(Q){Se=Q,N=void 0,se+1<B&&e.onSceneRetry?.(R.key,se+2,B,t.timeoutMs,Q);}if(!N)throw new Error(`Shader capture "${R.key}" failed after ${B} attempts: ${Se instanceof Error?Se.message:String(Se)}`);if(x.set(W,N),h.push({scene:R.key,backend:F,attempts:se+1,coverage:N.coverage,skipped:N.skipped.length,startupBuilds:N.stats.registeredBuilds,startupBuildMs:N.stats.buildMs,...N.timing===void 0?{}:{timing:N.timing}}),_&&j!==void 0){await $();let Q=new Map(t.scenes.map(G=>{let Fe=e$1(G,o),ae=G.key===R.key?v.get(G.key):Fe.map(J=>j?.scenes[g(G.key,J)]?.inputs).find(J=>J!==void 0);if(ae===void 0)throw new Error(`Shader checkpoint is missing scene "${G.key}".`);return O!==void 0&&!Fe.every(J=>x.has(g(G.key,J)))&&(ae={...ae,[xr]:O}),[G.key,ae]}));K=await j$2({root:r,scenes:t.scenes,backends:o,captures:new Map([[W,N]]),runtime:i$1,inputs:Q,previousReceipt:j,publicDirectory:t.publicDir??"public"}),j=K.receipt;}}await $(),K=await j$2({root:r,scenes:t.scenes,backends:o,captures:x,runtime:i$1,inputs:v,...f===void 0?{}:{previousReceipt:f},publicDirectory:t.publicDir??"public"});let S={...a$1};for(let g$1 of h)S[g(g$1.scene,g$1.backend)]={builds:g$1.coverage.render+g$1.coverage.compute,setupMeasured:!1,liveBuildMs:g$1.startupBuildMs,precompiledBuildMs:0,avoidedBuildMs:g$1.startupBuildMs,runs:1,spreadMs:0};if(e.commitTiming===!0){let g=u??{adapter:x.values().next().value?.provenance?.adapter??"WebGPU adapter",platform:`${Ae.platform()}/${Ae.arch()}`},M=p.values().next().value??e.driver;await i$2(r,S,await(M?.timingEnvironment?.()??g));}else await f$2(r,S);let k=await readFile(L.join(K.directory,"meta.json")),y=await e$2(K.directory,k);return {schemaVersion:1,root:r,skipped:!1,reason:`Wrote ${h.length} shader scene${h.length===1?"":"s"}.`,durationMs:performance.now()-w,scenes:h,measurement:{beforeBuilds:h.reduce((g,M)=>g+M.startupBuilds,0),afterBuilds:0,firstFrameDeltaMs:-h.reduce((g,M)=>g+M.startupBuildMs,0),source:"capture-build-phase"},...n===void 0?{}:{configuration:{created:n.created,file:n.file}},written:K,...y===void 0?{}:{timing:y}}}finally{D&&await Promise.all([...p.values()].map(S=>S.close()));}}a(Vt,"captureShaders");function at(e){return ["workerReady","assetsReady",...e.requiresText?["textReady"]:[],"compileEnd","firstFrame"]}a(at,"requiredReadiness");function Rr(e){if(e.length===0)throw new Error("Cannot take the median of an empty shader timing capture.");let r=[...e].sort((s,c)=>s-c),n=Math.floor(r.length/2),t=r[n];if(t===void 0)throw new Error("Shader timing median is unavailable.");if(r.length%2===1)return t;let i=r[n-1];if(i===void 0)throw new Error("Shader timing median pair is unavailable.");return (i+t)/2}a(Rr,"median");function er(e,r,n,t){if(e.scene!==r.key||e.mode!==n)throw new Error(`Browser observation identity differs for scene "${r.key}".`);if(e.compatibility!==t||e.transform!==b)throw new Error(`Browser observation compatibility differs for scene "${r.key}".`);let i=at(r).filter(s=>e.readiness[s]!==true);if(i.length>0)throw new Error(`Scene "${r.key}" ${n} observation is missing readiness bits: ${i.join(", ")}.`);if(e.errors.length>0)throw new Error(`Scene "${r.key}" ${n} browser errors:
|
|
11
|
-
- ${e.errors.join(`
|
|
12
|
-
- `)}
|
|
13
|
-
${n} demands: ${rr(e.demands)}`)}a(er,"assertObservation");async function ot(e,r,n){if(n===void 0)return new Set;try{let t=JSON.parse(await readFile(L.join(e,r.publicDir??"public",n),"utf8"));return new Set(Object.keys(t.fallbacks??{}))}catch{return new Set}}a(ot,"manifestFallbackKeys");function dt(e,r,n,t,i,s){if(r.render>0&&n.stats.registeredRenderBuilds===0)throw new Error(`Scene "${e.key}" live baseline exercised no registered render pipeline.`);if(r.compute>0&&n.stats.registeredComputeBuilds===0)throw new Error(`Scene "${e.key}" live baseline exercised no registered compute kernel.`);Tr(e,r,t,i,s,n.demands);}a(dt,"assertZeroBuild");function rr(e){return !e||e.length===0?"none recorded":e.map(r=>`${String(r.key??"unregistered")}[${String(r.event)}${r.hit===false?":miss":""}|${String(r.target)}${r.object===void 0?"":`@${String(r.object)}`}]`).join(" ").slice(0,4e3)}a(rr,"describeDemands");function Tr(e,r,n,t,i,s){let c=a(()=>`
|
|
14
|
-
Precompiled demands: ${rr(n.demands)}`+(s===void 0?"":`
|
|
15
|
-
Live demands: ${rr(s)}`),"demandEvidence");if(n.stats.registeredRenderBuilds+n.stats.registeredComputeBuilds>t){let o=n.stats.missedKeys??[];throw new Error(`Scene "${e.key}" injected path performed ${n.stats.registeredRenderBuilds} render and ${n.stats.registeredComputeBuilds} compute registered live builds; capture permits ${t}.`+(o.length>0?` Missed keys: ${o.join(", ")}.`:"")+c())}if(n.stats.buildCalls>t)throw new Error(`Scene "${e.key}" injected path performed ${n.stats.buildCalls} total live NodeBuilder build${n.stats.buildCalls===1?"":"s"}; capture permits ${t} skipped live build${t===1?"":"s"}.`);if(r.render>0&&n.stats.injectedRender===0)throw new Error(`Scene "${e.key}" injected no render entries.`);if(r.compute>0&&n.stats.injectedCompute===0)throw new Error(`Scene "${e.key}" injected no compute entries.`);if(n.stats.missed!==0||n.stats.missedRender!==0||n.stats.missedCompute!==0){let o=n.stats.missedKeys??[],m=o.filter(f=>!i.has(f)),l=o.length>0&&n.stats.missed<=i.size;if(m.length>0||!l)throw new Error(`Scene "${e.key}" injected path reported shader manifest misses.`+(o.length>0?` Missed keys: ${o.join(", ")}.`:"")+(m.length>0&&m.length!==o.length?` Unexpected: ${m.join(", ")}.`:"")+c())}}a(Tr,"assertPrecompiledZeroBuild");async function ct(e,r,n,t,i){let s=L.join(e,c$3);if(await d(s)){let o=await lstat(s);if(o.isSymbolicLink()||!o.isDirectory())throw new Error("Shader parity artifact directory is not a real directory.")}else await mkdir(s,{recursive:true});let c=[`${r}.live.png`,`${r}.precompiled.png`,`${r}.diff.png`];return await Promise.all([n,t,i].map(async(o,m)=>{let l=c[m];if(l===void 0)throw new Error("Parity artifact mapping failed.");let f=L.join(s,l);if(await d(f)){let a=await lstat(f);if(a.isSymbolicLink()||!a.isFile())throw new Error(`Shader parity target is not a regular file: ${l}.`)}await writeFile(f,o,{mode:384});})),c.map(o=>`${c$3}/${o}`)}a(ct,"writeParityFailure");async function Ht(e={}){let r=e.root?await realpath(e.root):await i(e.start),n=e.runtime??await we(r),t=e.config??await j$1(r),i$1=d$1(e.backend??t.backend),s=f$1(t.scenes,[...i$1].reverse()),c=await De(r,n,e.backend??t.backend);if(c.state!=="fresh")throw new Error(`Shader no-GPU validation is ${c.state}: ${c.reason}`);if(e.skipBrowser)return {schemaVersion:1,root:r,noGpu:c,browser:"skipped",scenes:[]};if(e.parityOnly===true&&e.commitTiming===true)throw new Error("Parity-only shader verification cannot commit timing.");let o=e.runs??5;if(!Number.isSafeInteger(o)||o<1||o>100)throw new Error("Shader timing runs must be an integer in 1...100.");let m=await readFile(L.join(r,b$1,"meta.json")),l=c$1(JSON.parse(m.toString("utf8")));if(c.receipt===void 0||d$2(l)!==d$2(c.receipt))throw new Error("Shader receipt changed after no-GPU validation; restart browser parity verification.");let f=e.driver===void 0,a$1=e.driver===void 0&&e.driverKind===void 0&&e.serve===void 0&&e.url===void 0?await k$1(r):void 0,u=e.serve??a$1?.serve,w=e.driverKind??a$1?.driverKind??(u===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(w==="vite"&&u!==void 0)throw new Error("--serve requires the static shader driver.");if(w==="static"&&u===void 0&&e.driver===void 0)throw new Error("The static shader driver requires --serve <built-directory>.");let O=e.driver===void 0?await import('./shader-browser-H5CB2ZQX.js'):void 0,{compareShaderScreenshots:V}=await import('./shader-parity-XPKQQK26.js'),v=a(()=>e.url!==void 0?O.createAttachedPlaywrightShaderDriver({root:r,runtime:n,url:e.url,...e.headed!==void 0?{headed:e.headed}:{}}):w==="static"?O.createStaticPlaywrightShaderDriver({root:r,runtime:n,serve:u,...e.headed!==void 0?{headed:e.headed}:{}}):O.createPlaywrightShaderDriver({root:r,runtime:n,...e.headed!==void 0?{headed:e.headed}:{}}),"createDriver"),$=new Map,D=new Map,T=a((p,b)=>{if(e.driver!==void 0)return e.driver;let x=p.get(b);return x===void 0&&(x=v(),p.set(b,x)),x},"driverFor");await h$1(r,s.map(p=>p.key),m);let A=[],C={},H=[],q=new Set;try{for(let[b,x]of s.entries()){let{scene:h,backend:_,key:j}=x;e.onSceneStart?.(j,b,s.length);let K=c.scenes.find(P=>P.scene===h.key&&P.backend===_);if(!K?.coverage)throw new Error(`Fresh receipt has no coverage for "${j}".`);let B=K.coverage;if(B.render+B.compute===0)continue;let S=a$4(n.three,_),k=c.receipt?.scenes[j]?.skipped,y=(k?.render??0)+(k?.compute??0),g=await ot(r,t,c.receipt?.scenes[j]?.asset),M=a(async P=>{let oe=T($,_),Re=T(D,_),ee=P?"live":"precompiled",$e=P?"precompiled":"live",xe=P?oe:Re,Te=P?Re:oe,ne=await xe.observe(h,ee,t,void 0,_),I=await Te.observe(h,$e,t,ne.frame,_),de=ne.mode==="live"?ne:I,ce=ne.mode==="precompiled"?ne:I;er(de,h,"live",S),er(ce,h,"precompiled",S),dt(h,B,de,ce,y,g);let tr=a(async(Mr,nr,ir)=>{let Y=V(nr,ir,t.parity.channelTolerance,h.maxDiffRatio??t.parity.maxDiffRatio);if(Y.matches)return Y;let Pr=await ct(r,j,nr,ir,Y.diff),Ir=Y.nonBlack?`${Y.differentPixels}/${Y.totalPixels} pixels differ (${(Y.diffRatio*100).toFixed(3)}%).`:`rendered output is black (live=${Y.baselineLuminance.toFixed(4)}, precompiled=${Y.precompiledLuminance.toFixed(4)}).`;throw new Error(`Shader ${Mr} parity failed for scene "${h.key}" at completed frames live=${de.frame}, precompiled=${ce.frame}: ${Ir} Artifacts: ${Pr.join(", ")}`)},"compare");await tr("first frame",de.firstFrameScreenshot,ce.firstFrameScreenshot);let Br=await tr("settled",de.screenshot,ce.screenshot);return {live:de,precompiled:ce,parity:Br}},"observePair"),R,F,W;if(e.parityOnly===!0)try{R=await M(!0);}catch(P){nt(P)&&q.add(j),H.push({scene:j,error:P}),e.onSceneError?.(j,P);continue}else {await M(!0);let P=[];for(let I=0;I<o;I++)P.push(await M(I%2===0));let oe=P[P.length-1];if(oe===void 0)throw new Error(`Shader timing produced no runs for scene "${h.key}".`);if(R=oe,F=await T(D,_).observePublished(h,t,_),er(F,h,"precompiled",S),Tr(h,B,F,y,g),W=h.runtimeMotion?V(F.beforeScreenshot,F.screenshot,t.parity.channelTolerance,1):void 0,W&&W.diffRatio<1e-4)throw new Error(`Published scene "${h.key}" stopped animating during its normal 120-frame soak (changed ${W.differentPixels}/${W.totalPixels} canvas pixels).`);let ee=a(I=>I.stats.buildMs+(I.stats.precompiledSetupMs??0)+(I.stats.hydrationMs??0),"observedNodeBuilderMs"),$e=Rr(P.map(I=>ee(I.live))),xe=Rr(P.map(I=>ee(I.precompiled))),Te=Math.max(0,$e-xe),ne=P.map(I=>Math.max(0,ee(I.live)-ee(I.precompiled)));C[j]={builds:B.render+B.compute,setupMeasured:!0,liveBuildMs:$e,precompiledBuildMs:xe,avoidedBuildMs:Te,runs:o,spreadMs:Math.max(...ne.map(I=>Math.abs(I-Te)))};}let{diff:Ee,...N}=R.parity,{firstFrameScreenshot:Se,screenshot:se,...Q}=R.live,{firstFrameScreenshot:G,screenshot:Fe,...ae}=R.precompiled,J;if(F!==void 0){let{beforeScreenshot:P,firstFrameScreenshot:oe,screenshot:Re,...ee}=F;J=ee;}A.push({scene:h.key,backend:_,coverage:B,live:Q,precompiled:ae,...J===void 0?{}:{published:J},parity:N,...W===void 0?{}:{runtimeMotion:{differentPixels:W.differentPixels,totalPixels:W.totalPixels,diffRatio:W.diffRatio}}}),await g$1(r,[j],m);}if(e.parityOnly===!0){if(await it(r,[...q],m),H.length>0)throw new Error(`Shader parity failed for ${H.length}/${s.length} scene/backend pair(s):
|
|
16
|
-
`+H.map(b=>{let x=b.error instanceof Error?b.error.message:String(b.error);return ` - ${b.scene}: ${x}`}).join(`
|
|
17
|
-
`));return {schemaVersion:1,root:r,noGpu:c,browser:"passed",scenes:A}}if(Object.keys(C).length===0)return {schemaVersion:1,root:r,noGpu:c,browser:"passed",scenes:A};if(e.commitTiming===!0){let b={adapter:i$1.length===1&&i$1[0]==="webgl"?"WebGL adapter":"WebGPU adapter",platform:`${Ae.platform()}/${Ae.arch()}`},h=await(($.values().next().value??e.driver)?.timingEnvironment?.()??b),_=await i$2(r,C,h);return {schemaVersion:1,root:r,noGpu:c,browser:"passed",scenes:A,timing:_.local,committedTiming:_.committed}}let p=await f$2(r,C);return {schemaVersion:1,root:r,noGpu:c,browser:"passed",scenes:A,timing:p}}finally{f&&await Promise.all([...$.values(),...D.values()].map(p=>p.close()));}}a(Ht,"testShaders");export{wr as a,Ce as b,we as c,De as d,Vt as e,Ht as f};
|
package/dist/chunk-MIUIIPS4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {V,W}from'./chunk-NF4RFSUJ.js';import {a}from'./chunk-EI7MMDWY.js';import {existsSync,readFileSync,readFile}from'fs';import {createRequire}from'module';import d from'path';var m="@three-blocks/devtools/webpack-loader";function y(e){if(typeof e=="string")return e===m;if(Array.isArray(e))return e.some(y);if(e===null||typeof e!="object")return false;let o=e;return o.loader===m||y(o.use)}a(y,"webpackRuleUsesShaderLoader");function T(e){let o=b(process.cwd()),r=a(t=>x(o,t),"exact"),n={...e.resolve?.alias,...r("three")===void 0?{}:{three$:r("three")},...r("three/webgpu")===void 0?{}:{"three/webgpu$":r("three/webgpu")},...r("three/tsl")===void 0?{}:{"three/tsl$":r("three/tsl")},"three/addons":d.join(o.root,"examples/jsm"),"three/examples/jsm":d.join(o.root,"examples/jsm")};return {...e,resolve:{...e.resolve,alias:n}}}a(T,"withTargetThreeAliases");function w(e){let o=T(e),r=o.module?.rules??[];return r.some(y)?o:{...o,module:{...o.module,rules:[...r,{enforce:"pre",test:/three[\\/]build[\\/]three\.webgpu\.js$/u,use:[{loader:m}]}]}}}a(w,"withShaderWebpackRule");function A(e){return w(e)}a(A,"withThreeBlocksWebpack");function B(e){let r=e.webpack;return {...e,webpack(n,...t){let s=r?.call(this,n,...t)??n,i=t[0];return i!==null&&typeof i=="object"&&Reflect.get(i,"isServer")===true?T(s):w(s)}}}a(B,"withThreeBlocksNext");function b(e){let o;try{o=createRequire(d.join(d.resolve(e),"package.json")).resolve("three");}catch(s){throw new Error("The shader adapter could not resolve Three.js from the target project.",{cause:s})}let r=d.dirname(o),n,t;for(;;){let s=d.join(r,"package.json");if(existsSync(s)){let l=JSON.parse(readFileSync(s,"utf8"));if(l.name==="three"){n=s,t=l;break}}let i=d.dirname(r);if(i===r)break;r=i;}if(n===void 0)throw new Error(`The shader adapter could not locate Three.js package metadata from ${o}.`);if(typeof t?.version!="string"||t.version.length===0)throw new Error(`The resolved Three.js package has no version: ${n}`);return {root:d.dirname(n),version:t.version,exports:t.exports}}a(b,"resolveThreePackage");function L(e=process.cwd()){return b(e).version}a(L,"resolveShaderAdapterThreeVersion");function v(e){return {version:e.threeVersion??L(e.root),capture:e.capture??process.env.THREE_BLOCKS_SHADER_TOOL==="1"}}a(v,"resolvedOptions");function _(e,o,r={}){if(!V(o))return null;let n=v(r);return W(e,n.version,{instrumentCapture:n.capture})}a(_,"transformThreeWebGPUModule");function g(e){if(typeof e=="string")return e;if(Array.isArray(e)){for(let r of e){let n=g(r);if(n!==void 0)return n}return}if(e===null||typeof e!="object")return;let o=e;for(let r of ["browser","import","default"]){let n=g(o[r]);if(n!==void 0)return n}}a(g,"exportTarget");function x(e,o){if(e.exports===null||typeof e.exports!="object")return;let r=e.exports,n=o==="three"?".":`./${o.slice(6)}`,t=g(r[n]);if(t!==void 0)return d.resolve(e.root,t);for(let[s,i]of Object.entries(r)){let l=s.indexOf("*");if(l<0)continue;let c=s.slice(0,l),u=s.slice(l+1);if(!n.startsWith(c)||!n.endsWith(u))continue;let f=n.slice(c.length,n.length-u.length),p=g(i);if(p!==void 0)return d.resolve(e.root,p.replaceAll("*",f))}}a(x,"resolveThreeExport");function $(e={}){let o=e.root??process.cwd(),r=b(o),n={version:e.threeVersion??r.version,capture:e.capture??process.env.THREE_BLOCKS_SHADER_TOOL==="1"};return {name:"three-blocks-shader-provider",setup(t){t.onResolve?.({filter:/^three(?:\/.*)?$/},s=>{let i=x(r,s.path);return i===void 0?void 0:{path:i}}),t.onLoad({filter:/three[\\/]build[\\/]three\.webgpu\.js$/},async s=>{let i=await new Promise((c,u)=>{readFile(s.path,"utf8",(f,p)=>{f?u(f):c(p);});});return {contents:W(i,n.version,{instrumentCapture:n.capture}).code,loader:"js"}});}}}a($,"createEsbuildShaderPlugin");function H(e={}){let o=v(e);return {name:"three-blocks-shader-provider",enforce:"pre",transform(r,n){return V(n)?{code:W(r,o.version,{instrumentCapture:o.capture}).code,map:null}:null}}}a(H,"createRollupShaderPlugin");export{m as a,A as b,B as c,L as d,_ as e,$ as f,H as g};
|