@agent-play/play-ui 3.5.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{browserAll-CzHvM3Eh.js → browserAll-CyzKL7LJ.js} +1 -1
- package/dist/assets/index-BN8bwUYb.js +336 -0
- package/dist/assets/webworkerAll-CTAzpwMx.js +83 -0
- package/dist/index.html +1 -1
- package/package.json +4 -3
- package/dist/assets/index-C0EYdIvE.js +0 -298
- package/dist/assets/webworkerAll-Br0_723U.js +0 -83
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import{S as H,b as L,G as B,c as U,D as y,d as S,g as b,n as R,f as j,M as V,B as P,h as F,E as C,i as N,j as $,k as I,l as J,R as K,w as Q,e as E}from"./index-BN8bwUYb.js";const W=class k extends H{constructor(e){e={...k.defaultOptions,...e},super(e),this.enabled=!0,this._state=L.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1),e.blendRequired&&this.addResource("uBackTexture",0,3)}apply(e,t,n,r){e.applyFilter(this,t,n,r)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:n,...r}=e;let i,a;return t&&(i=B.from(t)),n&&(a=U.from(n)),new k({gpuProgram:i,glProgram:a,...r})}};W.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let Z=W,w;function M(c){const e=y.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=c,t.fillRect(0,0,6,1),e}function ee(){if(w!==void 0)return w;try{const c=M("#ff00ff"),e=M("#ffff00"),n=y.get().createCanvas(6,1).getContext("2d");n.globalCompositeOperation="multiply",n.drawImage(c,0,0),n.drawImage(e,2,0);const r=n.getImageData(2,0,1,1);if(!r)w=!1;else{const i=r.data;w=i[0]===255&&i[1]===0&&i[2]===0}}catch{w=!1}return w}const p={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:ee(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:c=>{const e=c.source,t=e==null?void 0:e.resource;if(!t)return null;const n=e.alphaMode==="premultiplied-alpha",r=e.resourceWidth??e.pixelWidth,i=e.resourceHeight??e.pixelHeight,a=r!==e.pixelWidth||i!==e.pixelHeight;if(n){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!a)return t;const s=p._unpremultipliedCache.get(e);if((s==null?void 0:s.resourceId)===e._resourceId)return s.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){const s=p._canvasSourceCache.get(e);if((s==null?void 0:s.resourceId)===e._resourceId)return s.canvas;const o=y.get().createCanvas(e.pixelWidth,e.pixelHeight),l=o.getContext("2d"),d=l.createImageData(e.pixelWidth,e.pixelHeight),u=d.data,h=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.format==="bgra8unorm")for(let f=0;f<u.length&&f+3<h.length;f+=4)u[f]=h[f+2],u[f+1]=h[f+1],u[f+2]=h[f],u[f+3]=h[f+3];else u.set(h.subarray(0,u.length));return l.putImageData(d,0,0),p._canvasSourceCache.set(e,{canvas:o,resourceId:e._resourceId}),o}if(n){const s=y.get().createCanvas(e.pixelWidth,e.pixelHeight),o=s.getContext("2d",{willReadFrequently:!0});s.width=e.pixelWidth,s.height=e.pixelHeight,o.drawImage(t,0,0);const l=o.getImageData(0,0,s.width,s.height),d=l.data;for(let u=0;u<d.length;u+=4){const h=d[u+3];if(h>0){const f=255/h;d[u]=Math.min(255,d[u]*f+.5),d[u+1]=Math.min(255,d[u+1]*f+.5),d[u+2]=Math.min(255,d[u+2]*f+.5)}}return o.putImageData(l,0,0),p._unpremultipliedCache.set(e,{canvas:s,resourceId:e._resourceId}),s}if(a){const s=p._canvasSourceCache.get(e);if((s==null?void 0:s.resourceId)===e._resourceId)return s.canvas;const o=y.get().createCanvas(e.pixelWidth,e.pixelHeight),l=o.getContext("2d");return o.width=e.pixelWidth,o.height=e.pixelHeight,l.drawImage(t,0,0),p._canvasSourceCache.set(e,{canvas:o,resourceId:e._resourceId}),o}return t},getTintedCanvas:(c,e)=>{const t=c.texture,n=S.shared.setValue(e).toHex(),r=t.tintCache||(t.tintCache={}),i=r[n],a=t.source._resourceId;if((i==null?void 0:i.tintId)===a)return i;const s=i&&"getContext"in i?i:y.get().createCanvas();return p.tintMethod(t,e,s),s.tintId=a,r[n]=s,r[n]},getTintedPattern:(c,e)=>{const t=S.shared.setValue(e).toHex(),n=c.patternCache||(c.patternCache={}),r=c.source._resourceId;let i=n[t];return(i==null?void 0:i.tintId)===r||(p.canvas||(p.canvas=y.get().createCanvas()),p.tintMethod(c,e,p.canvas),i=p.canvas.getContext("2d").createPattern(p.canvas,"repeat"),i.tintId=r,n[t]=i),i},applyPatternTransform:(c,e,t=!0)=>{if(!e)return;const n=c;if(!n.setTransform)return;const r=globalThis.DOMMatrix;if(!r)return;const i=new r([e.a,e.b,e.c,e.d,e.tx,e.ty]);n.setTransform(t?i.inverse():i)},tintWithMultiply:(c,e,t)=>{const n=t.getContext("2d"),r=c.frame.clone(),i=c.source._resolution??c.source.resolution??1,a=c.rotate;r.x*=i,r.y*=i,r.width*=i,r.height*=i;const s=b.isVertical(a),o=s?r.height:r.width,l=s?r.width:r.height;t.width=Math.ceil(o),t.height=Math.ceil(l),n.save(),n.fillStyle=S.shared.setValue(e).toHex(),n.fillRect(0,0,o,l),n.globalCompositeOperation="multiply";const d=p.getCanvasSource(c);if(!d){n.restore();return}a&&p._applyInverseRotation(n,a,r.width,r.height),n.drawImage(d,r.x,r.y,r.width,r.height,0,0,r.width,r.height),n.globalCompositeOperation="destination-atop",n.drawImage(d,r.x,r.y,r.width,r.height,0,0,r.width,r.height),n.restore()},tintWithOverlay:(c,e,t)=>{const n=t.getContext("2d"),r=c.frame.clone(),i=c.source._resolution??c.source.resolution??1,a=c.rotate;r.x*=i,r.y*=i,r.width*=i,r.height*=i;const s=b.isVertical(a),o=s?r.height:r.width,l=s?r.width:r.height;t.width=Math.ceil(o),t.height=Math.ceil(l),n.save(),n.globalCompositeOperation="copy",n.fillStyle=S.shared.setValue(e).toHex(),n.fillRect(0,0,o,l),n.globalCompositeOperation="destination-atop";const d=p.getCanvasSource(c);if(!d){n.restore();return}a&&p._applyInverseRotation(n,a,r.width,r.height),n.drawImage(d,r.x,r.y,r.width,r.height,0,0,r.width,r.height),n.restore()},tintWithPerPixel:(c,e,t)=>{const n=t.getContext("2d"),r=c.frame.clone(),i=c.source._resolution??c.source.resolution??1,a=c.rotate;r.x*=i,r.y*=i,r.width*=i,r.height*=i;const s=b.isVertical(a),o=s?r.height:r.width,l=s?r.width:r.height;t.width=Math.ceil(o),t.height=Math.ceil(l),n.save(),n.globalCompositeOperation="copy";const d=p.getCanvasSource(c);if(!d){n.restore();return}a&&p._applyInverseRotation(n,a,r.width,r.height),n.drawImage(d,r.x,r.y,r.width,r.height,0,0,r.width,r.height),n.restore();const u=e>>16&255,h=e>>8&255,f=e&255,m=n.getImageData(0,0,o,l),g=m.data;for(let x=0;x<g.length;x+=4)g[x]=g[x]*u/255,g[x+1]=g[x+1]*h/255,g[x+2]=g[x+2]*f/255;n.putImageData(m,0,0)},_applyInverseRotation:(c,e,t,n)=>{const r=b.inv(e),i=b.uX(r),a=b.uY(r),s=b.vX(r),o=b.vY(r),l=-Math.min(0,i*t,s*n,i*t+s*n),d=-Math.min(0,a*t,o*n,a*t+o*n);c.transform(i,a,s,o,l,d)}};p.tintMethod=p.canUseMultiply?p.tintWithMultiply:p.tintWithPerPixel;class te{constructor(e){this._canvasPool=Object.create(null),this.canvasOptions=e||{},this.enableFullScreen=!1}_createCanvasAndContext(e,t){const n=y.get().createCanvas();n.width=e,n.height=t;const r=n.getContext("2d");return{canvas:n,context:r}}getOptimalCanvasAndContext(e,t,n=1){e=Math.ceil(e*n-1e-6),t=Math.ceil(t*n-1e-6),e=R(e),t=R(t);const r=(e<<17)+(t<<1);this._canvasPool[r]||(this._canvasPool[r]=[]);let i=this._canvasPool[r].pop();return i||(i=this._createCanvasAndContext(e,t)),i}returnCanvasAndContext(e){const t=e.canvas,{width:n,height:r}=t,i=(n<<17)+(r<<1);e.context.resetTransform(),e.context.clearRect(0,0,n,r),this._canvasPool[i].push(e)}clear(){this._canvasPool={}}}const z=new te;j.register(z);const O=new V;function Y(c,e){e.clear();const t=e.matrix;for(let n=0;n<c.length;n++){const r=c[n];if(r.globalDisplayStatus<7)continue;const i=r.renderGroup??r.parentRenderGroup;i!=null&&i.isCachedAsTexture?e.matrix=O.copyFrom(i.textureOffsetInverseTransform).append(r.worldTransform):i!=null&&i._parentCacheAsTextureRenderGroup?e.matrix=O.copyFrom(i._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(r.groupTransform):e.matrix=r.worldTransform,e.addBounds(r.bounds)}return e.matrix=t,e}const re=new P;function ne(c,e,t,n,r=!1){const i=re;i.minX=0,i.minY=0,i.maxX=c.width/n|0,i.maxY=c.height/n|0;const a=F.getOptimalTexture(i.width,i.height,n,!1,r);return a.source.uploadMethodId="image",a.source.resource=c,a.source.alphaMode="premultiply-alpha-on-upload",a.frame.width=e/n,a.frame.height=t/n,a.source.emit("update",a.source),a.updateUvs(),a}function G(c){return typeof c.getCanvasFilterString=="function"}class ie{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new P,this.cssFilterString=""}}class q{constructor(e){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=e}push(e){const t=this._pushFilterFrame(),n=e.filterEffect.filters;if(t.skip=!1,t.useClip=!1,t.filters=n,t.container=e.container,t.cssFilterString="",n.every(o=>!o.enabled)){t.skip=!0;return}const r=[],i=1;for(const o of n){if(!o.enabled)continue;if(!G(o)){this._warnUnsupportedFilter(o);continue}const l=o.getCanvasFilterString();if(l===null){this._warnUnsupportedFilter(o);continue}l&&r.push(l)}if(r.length===0&&i===1){t.skip=!0;return}t.cssFilterString=r.join(" "),this._calculateFilterArea(e,t.bounds),t.useClip=!!e.filterEffect.filterArea;const a=this.renderer.canvasContext.activeContext,s=a.filter||"none";if(this._savedStates.push({filter:s,alphaMultiplier:this._alphaMultiplier}),t.useClip&&Number.isFinite(t.bounds.width)&&Number.isFinite(t.bounds.height)&&t.bounds.width>0&&t.bounds.height>0){const o=this.renderer.canvasContext.activeResolution||1;a.save(),a.setTransform(1,0,0,1,0,0),a.beginPath(),a.rect(t.bounds.x*o,t.bounds.y*o,t.bounds.width*o,t.bounds.height*o),a.clip()}else t.useClip=!1;t.cssFilterString&&(a.filter=s!=="none"?`${s} ${t.cssFilterString}`:t.cssFilterString)}pop(){const e=this._popFilterFrame();if(e.skip)return;const t=this._savedStates.pop();if(!t)return;const n=this.renderer.canvasContext.activeContext;e.useClip?n.restore():n.filter=t.filter,this._alphaMultiplier=t.alphaMultiplier}generateFilteredTexture({texture:e,filters:t}){if(!(t!=null&&t.length)||t.every(v=>!v.enabled))return e;const n=[],r=1;for(const v of t){if(!v.enabled)continue;if(!G(v)){this._warnUnsupportedFilter(v);continue}const T=v.getCanvasFilterString();if(T===null){this._warnUnsupportedFilter(v);continue}T&&n.push(T)}if(n.length===0&&r===1)return e;const i=p.getCanvasSource(e);if(!i)return e;const a=e.frame,s=e.source._resolution??e.source.resolution??1,o=a.width,l=a.height,d=z.getOptimalCanvasAndContext(o,l,s),{canvas:u,context:h}=d;h.setTransform(1,0,0,1,0,0),h.clearRect(0,0,u.width,u.height),n.length&&(h.filter=n.join(" "));const f=a.x*s,m=a.y*s,g=o*s,x=l*s;return h.drawImage(i,f,m,g,x,0,0,g,x),h.filter="none",h.globalAlpha=1,ne(u,o,l,s)}_calculateFilterArea(e,t){if(e.renderables?Y(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){const n=e.container.renderGroup||e.container.parentRenderGroup,r=n==null?void 0:n.cacheToLocalTransform;r&&t.applyMatrix(r)}}_warnUnsupportedFilter(e){var n;const t=((n=e==null?void 0:e.constructor)==null?void 0:n.name)||"Filter";this._warnedFilterTypes.has(t)||(this._warnedFilterTypes.add(t),console.warn(`CanvasRenderer: filter "${t}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let e=this._filterStack[this._filterStackIndex];return e||(e=this._filterStack[this._filterStackIndex]=new ie),this._filterStackIndex++,e}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}}q.extension={type:[C.CanvasSystem],name:"filter"};var ae=`in vec2 aPosition;
|
|
2
|
+
out vec2 vTextureCoord;
|
|
3
|
+
|
|
4
|
+
uniform vec4 uInputSize;
|
|
5
|
+
uniform vec4 uOutputFrame;
|
|
6
|
+
uniform vec4 uOutputTexture;
|
|
7
|
+
|
|
8
|
+
vec4 filterVertexPosition( void )
|
|
9
|
+
{
|
|
10
|
+
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
11
|
+
|
|
12
|
+
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
13
|
+
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
14
|
+
|
|
15
|
+
return vec4(position, 0.0, 1.0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
vec2 filterTextureCoord( void )
|
|
19
|
+
{
|
|
20
|
+
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
void main(void)
|
|
24
|
+
{
|
|
25
|
+
gl_Position = filterVertexPosition();
|
|
26
|
+
vTextureCoord = filterTextureCoord();
|
|
27
|
+
}
|
|
28
|
+
`,se=`in vec2 vTextureCoord;
|
|
29
|
+
out vec4 finalColor;
|
|
30
|
+
uniform sampler2D uTexture;
|
|
31
|
+
void main() {
|
|
32
|
+
finalColor = texture(uTexture, vTextureCoord);
|
|
33
|
+
}
|
|
34
|
+
`,A=`struct GlobalFilterUniforms {
|
|
35
|
+
uInputSize: vec4<f32>,
|
|
36
|
+
uInputPixel: vec4<f32>,
|
|
37
|
+
uInputClamp: vec4<f32>,
|
|
38
|
+
uOutputFrame: vec4<f32>,
|
|
39
|
+
uGlobalFrame: vec4<f32>,
|
|
40
|
+
uOutputTexture: vec4<f32>,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
|
|
44
|
+
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
45
|
+
@group(0) @binding(2) var uSampler: sampler;
|
|
46
|
+
|
|
47
|
+
struct VSOutput {
|
|
48
|
+
@builtin(position) position: vec4<f32>,
|
|
49
|
+
@location(0) uv: vec2<f32>
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
|
|
53
|
+
{
|
|
54
|
+
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
55
|
+
|
|
56
|
+
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
57
|
+
position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
58
|
+
|
|
59
|
+
return vec4(position, 0.0, 1.0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
|
|
63
|
+
{
|
|
64
|
+
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@vertex
|
|
68
|
+
fn mainVertex(
|
|
69
|
+
@location(0) aPosition: vec2<f32>,
|
|
70
|
+
) -> VSOutput {
|
|
71
|
+
return VSOutput(
|
|
72
|
+
filterVertexPosition(aPosition),
|
|
73
|
+
filterTextureCoord(aPosition)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@fragment
|
|
78
|
+
fn mainFragment(
|
|
79
|
+
@location(0) uv: vec2<f32>,
|
|
80
|
+
) -> @location(0) vec4<f32> {
|
|
81
|
+
return textureSample(uTexture, uSampler, uv);
|
|
82
|
+
}
|
|
83
|
+
`;class oe extends Z{constructor(){const e=B.from({vertex:{source:A,entryPoint:"mainVertex"},fragment:{source:A,entryPoint:"mainFragment"},name:"passthrough-filter"}),t=U.from({vertex:ae,fragment:se,name:"passthrough-filter"});super({gpuProgram:e,glProgram:t})}}class X{constructor(e){this._renderer=e}push(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:t,filterEffect:e})}pop(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(e){e.action==="pushFilter"?this._renderer.filter.push(e):e.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}X.extension={type:[C.WebGLPipes,C.WebGPUPipes,C.CanvasPipes],name:"filter"};const le=new J({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class ce{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new P,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}}class D{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new N({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new $({}),this.renderer=e}get activeBackTexture(){var e;return(e=this._activeFilterData)==null?void 0:e.backTexture}push(e){const t=this.renderer,n=e.filterEffect.filters,r=this._pushFilterData();r.skip=!1,r.filters=n,r.container=e.container,r.outputRenderSurface=t.renderTarget.renderSurface;const i=t.renderTarget.renderTarget.colorTexture.source,a=i.resolution,s=i.antialias;if(n.every(f=>!f.enabled)){r.skip=!0;return}const o=r.bounds;if(this._calculateFilterArea(e,o),this._calculateFilterBounds(r,t.renderTarget.rootViewPort,s,a,1),r.skip)return;const l=this._getPreviousFilterData(),d=this._findFilterResolution(a);let u=0,h=0;l&&(u=l.bounds.minX,h=l.bounds.minY),this._calculateGlobalFrame(r,u,h,d,i.width,i.height),this._setupFilterTextures(r,o,t,l)}generateFilteredTexture({texture:e,filters:t}){const n=this._pushFilterData();this._activeFilterData=n,n.skip=!1,n.filters=t;const r=e.source,i=r.resolution,a=r.antialias;if(t.every(f=>!f.enabled))return n.skip=!0,e;const s=n.bounds;if(s.addRect(e.frame),this._calculateFilterBounds(n,s.rectangle,a,i,0),n.skip)return e;const o=i;this._calculateGlobalFrame(n,0,0,o,r.width,r.height),n.outputRenderSurface=F.getOptimalTexture(s.width,s.height,n.resolution,n.antialias),n.backTexture=I.EMPTY,n.inputTexture=e,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(n,!0);const h=n.outputRenderSurface;return h.source.alphaMode="premultiplied-alpha",h}pop(){const e=this.renderer,t=this._popFilterData();t.skip||(e.globalUniforms.pop(),e.renderTarget.finishRenderPass(),this._activeFilterData=t,this._applyFiltersToTexture(t,!1),t.blendRequired&&F.returnTexture(t.backTexture),F.returnTexture(t.inputTexture))}getBackTexture(e,t,n){const r=e.colorTexture.source._resolution,i=F.getOptimalTexture(t.width,t.height,r,!1);let a=t.minX,s=t.minY;n&&(a-=n.minX,s-=n.minY),a=Math.floor(a*r),s=Math.floor(s*r);const o=Math.ceil(t.width*r),l=Math.ceil(t.height*r);return this.renderer.renderTarget.copyToTexture(e,i,{x:a,y:s},{width:o,height:l},{x:0,y:0}),i}applyFilter(e,t,n,r){const i=this.renderer,a=this._activeFilterData,o=a.outputRenderSurface===n,l=i.renderTarget.rootRenderTarget.colorTexture.source._resolution,d=this._findFilterResolution(l);let u=0,h=0;if(o){const m=this._findPreviousFilterOffset();u=m.x,h=m.y}this._updateFilterUniforms(t,n,a,u,h,d,o,r);const f=e.enabled?e:this._getPassthroughFilter();this._setupBindGroupsAndRender(f,t,i)}calculateSpriteMatrix(e,t){const n=this._activeFilterData,r=e.set(n.inputTexture._source.width,0,0,n.inputTexture._source.height,n.bounds.minX,n.bounds.minY),i=t.worldTransform.copyTo(V.shared),a=t.renderGroup||t.parentRenderGroup;return a&&a.cacheToLocalTransform&&i.prepend(a.cacheToLocalTransform),i.invert(),r.prepend(i),r.scale(1/t.texture.orig.width,1/t.texture.orig.height),r.translate(t.anchor.x,t.anchor.y),r}destroy(){var e;(e=this._passthroughFilter)==null||e.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new oe),this._passthroughFilter}_setupBindGroupsAndRender(e,t,n){if(n.renderPipes.uniformBatch){const r=n.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(r,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(t.source,1),this._globalFilterBindGroup.setResource(t.source.style,2),e.groups[0]=this._globalFilterBindGroup,n.encoder.draw({geometry:le,shader:e,state:e._state,topology:"triangle-list"}),n.type===K.WEBGL&&n.renderTarget.finishRenderPass()}_setupFilterTextures(e,t,n,r){if(e.backTexture=I.EMPTY,e.inputTexture=F.getOptimalTexture(t.width,t.height,e.resolution,e.antialias),e.blendRequired){n.renderTarget.finishRenderPass();const i=n.renderTarget.getRenderTarget(e.outputRenderSurface);e.backTexture=this.getBackTexture(i,t,r==null?void 0:r.bounds)}n.renderTarget.bind(e.inputTexture,!0),n.globalUniforms.push({offset:t})}_calculateGlobalFrame(e,t,n,r,i,a){const s=e.globalFrame;s.x=t*r,s.y=n*r,s.width=i*r,s.height=a*r}_updateFilterUniforms(e,t,n,r,i,a,s,o){const l=this._filterGlobalUniforms.uniforms,d=l.uOutputFrame,u=l.uInputSize,h=l.uInputPixel,f=l.uInputClamp,m=l.uGlobalFrame,g=l.uOutputTexture;s?(d[0]=n.bounds.minX-r,d[1]=n.bounds.minY-i):(d[0]=0,d[1]=0),d[2]=e.frame.width,d[3]=e.frame.height,u[0]=e.source.width,u[1]=e.source.height,u[2]=1/u[0],u[3]=1/u[1],h[0]=e.source.pixelWidth,h[1]=e.source.pixelHeight,h[2]=1/h[0],h[3]=1/h[1],f[0]=.5*h[2],f[1]=.5*h[3],f[2]=e.frame.width*u[2]-.5*h[2],f[3]=e.frame.height*u[3]-.5*h[3];const x=this.renderer.renderTarget.rootRenderTarget.colorTexture;m[0]=r*a,m[1]=i*a,m[2]=x.source.width*a,m[3]=x.source.height*a,t instanceof I&&(t.source.resource=null);const v=this.renderer.renderTarget.getRenderTarget(t);this.renderer.renderTarget.bind(t,!!o),t instanceof I?(g[0]=t.frame.width,g[1]=t.frame.height):(g[0]=v.width,g[1]=v.height),g[2]=v.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(e){let t=this._filterStackIndex-1;for(;t>0&&this._filterStack[t].skip;)--t;return t>0&&this._filterStack[t].inputTexture?this._filterStack[t].inputTexture.source._resolution:e}_findPreviousFilterOffset(){let e=0,t=0,n=this._filterStackIndex;for(;n>0;){n--;const r=this._filterStack[n];if(!r.skip){e=r.bounds.minX,t=r.bounds.minY;break}}return{x:e,y:t}}_calculateFilterArea(e,t){if(e.renderables?Y(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){const r=(e.container.renderGroup||e.container.parentRenderGroup).cacheToLocalTransform;r&&t.applyMatrix(r)}}_applyFiltersToTexture(e,t){const n=e.inputTexture,r=e.bounds,i=e.filters,a=e.firstEnabledIndex,s=e.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(n.source.style,2),this._globalFilterBindGroup.setResource(e.backTexture.source,3),a===s)i[a].apply(this,n,e.outputRenderSurface,t);else{let o=e.inputTexture;const l=F.getOptimalTexture(r.width,r.height,o.source._resolution,!1);let d=l;for(let u=a;u<s;u++){const h=i[u];if(!h.enabled)continue;h.apply(this,o,d,!0);const f=o;o=d,d=f}i[s].apply(this,o,e.outputRenderSurface,t),F.returnTexture(l)}}_calculateFilterBounds(e,t,n,r,i){var v;const a=this.renderer,s=e.bounds,o=e.filters;let l=1/0,d=0,u=!0,h=!1,f=!1,m=!0,g=-1,x=-1;for(let T=0;T<o.length;T++){const _=o[T];if(!_.enabled)continue;if(g===-1&&(g=T),x=T,l=Math.min(l,_.resolution==="inherit"?r:_.resolution),d+=_.padding,_.antialias==="off"?u=!1:_.antialias==="inherit"&&u&&(u=n),_.clipToViewport||(m=!1),!!!(_.compatibleRenderers&a.type)){f=!1;break}if(_.blendRequired&&!(((v=a.backBuffer)==null?void 0:v.useBackBuffer)??!0)){Q("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),f=!1;break}f=!0,h||(h=_.blendRequired)}if(!f){e.skip=!0;return}if(m&&s.fitBounds(0,t.width/r,0,t.height/r),s.scale(l).ceil().scale(1/l).pad((d|0)*i),!s.isPositive){e.skip=!0;return}e.antialias=u,e.resolution=l,e.blendRequired=h,e.firstEnabledIndex=g,e.lastEnabledIndex=x}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let e,t=this._filterStackIndex-1;for(;t>0&&(t--,e=this._filterStack[t],!!e.skip););return e}_pushFilterData(){let e=this._filterStack[this._filterStackIndex];return e||(e=this._filterStack[this._filterStackIndex]=new ce),this._filterStackIndex++,e}}D.extension={type:[C.WebGLSystem,C.WebGPUSystem],name:"filter"};E.add(D,q);E.add(X);
|
package/dist/index.html
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-play/play-ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Vite-built watch canvas (Pixi.js) for Agent Play. Publishes static files under dist/ for self-hosting or embedding beside your own API.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -27,9 +27,10 @@
|
|
|
27
27
|
"test": "vitest run"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@
|
|
30
|
+
"@openai/agents": "^0.8.5",
|
|
31
|
+
"@agent-play/intercom": "^3.3.0",
|
|
31
32
|
"@agent-play/node-tools": "^3.1.0",
|
|
32
|
-
"@agent-play/sdk": "^3.1
|
|
33
|
+
"@agent-play/sdk": "^3.2.1",
|
|
33
34
|
"dompurify": "^3.3.3",
|
|
34
35
|
"marked": "^17.0.5",
|
|
35
36
|
"pixi.js": "^8.17.1"
|