@ivoryheart/herdr-world 0.1.1 → 0.2.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -0
- package/README.md +167 -28
- package/bin/herdr-world.mjs +66 -0
- package/package.json +18 -22
- package/THIRD_PARTY_NOTICES.md +0 -61
- package/UPSTREAM.md +0 -65
- package/bin/herdr-world +0 -133
- package/docs/world-assets.md +0 -51
- package/lib/bridges/linux-x64/herdr-world-bridge +0 -0
- package/lib/bridges/macos-arm64/herdr-world-bridge +0 -0
- package/lib/bridges/macos-x64/herdr-world-bridge +0 -0
- package/lib/herdr-world-launcher.sh +0 -533
- package/share/herdr-world/web/assets/BufferResource-TmONtVkO.js +0 -311
- package/share/herdr-world/web/assets/CanvasPool-C4EP4giG.js +0 -1
- package/share/herdr-world/web/assets/GraphTheme-DdAfatoM.js +0 -1
- package/share/herdr-world/web/assets/NoteMarkdownPreview-Crh3odMO.js +0 -29
- package/share/herdr-world/web/assets/SpacesSurface-KQpjWcgW.js +0 -1
- package/share/herdr-world/web/assets/WorldSurface-4GHZpnMP.js +0 -369
- package/share/herdr-world/web/assets/WorldThemeStage-Da7LFwo3.js +0 -1
- package/share/herdr-world/web/assets/__vite-browser-external-2447137e-BvRk9kiK.js +0 -0
- package/share/herdr-world/web/assets/browserAll-B258yZD2.js +0 -1
- package/share/herdr-world/web/assets/chunk-QTnfLwEv.js +0 -1
- package/share/herdr-world/web/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/share/herdr-world/web/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/share/herdr-world/web/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/share/herdr-world/web/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/share/herdr-world/web/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/share/herdr-world/web/assets/getBatchSamplersUniformGroup-D-hqfegN.js +0 -1
- package/share/herdr-world/web/assets/ghostty-web-CMdhZEut.js +0 -13
- package/share/herdr-world/web/assets/index-B8V-qiZs.js +0 -18
- package/share/herdr-world/web/assets/index-DSq8fuVk.css +0 -1
- package/share/herdr-world/web/assets/init-BCuNUfJx.js +0 -1
- package/share/herdr-world/web/assets/jsx-runtime-BWRPWl8p.js +0 -1
- package/share/herdr-world/web/assets/localUniformBit-BnogyqF-.js +0 -264
- package/share/herdr-world/web/assets/web-Bev77txP.js +0 -1
- package/share/herdr-world/web/assets/web-CCyAvF9M.js +0 -1
- package/share/herdr-world/web/assets/webworkerAll-B5q9qlVj.js +0 -1
- package/share/herdr-world/web/fonts/JetBrainsMonoNerdFontMono-Regular.woff2 +0 -0
- package/share/herdr-world/web/fonts/OFL.txt +0 -93
- package/share/herdr-world/web/herdr-logo-180.png +0 -0
- package/share/herdr-world/web/herdr-logo-192.png +0 -0
- package/share/herdr-world/web/herdr-logo-512.png +0 -0
- package/share/herdr-world/web/herdr-logo-maskable-192.png +0 -0
- package/share/herdr-world/web/herdr-logo-maskable-512.png +0 -0
- package/share/herdr-world/web/herdr-logo.svg +0 -6
- package/share/herdr-world/web/index.html +0 -25
- package/share/herdr-world/web/legal/Apache-2.0.txt +0 -190
- package/share/herdr-world/web/legal/LICENSE.txt +0 -22
- package/share/herdr-world/web/legal/PixiJS-MIT.txt +0 -21
- package/share/herdr-world/web/legal/THIRD_PARTY_NOTICES.md +0 -61
- package/share/herdr-world/web/legal/UPSTREAM.md +0 -65
- package/share/herdr-world/web/legal/manifest.json +0 -33
- package/share/herdr-world/web/legal/npm-licenses.txt +0 -1381
- package/share/herdr-world/web/legal/world-assets.md +0 -51
- package/share/herdr-world/web/manifest.json +0 -42
- package/share/herdr-world/web/world/LICENSE-PixiJS.txt +0 -21
- package/share/herdr-world/web/world/characters/1-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/10-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/11-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/12-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/2-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/3-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/4-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/5-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/6-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/7-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/8-D-1.png +0 -0
- package/share/herdr-world/web/world/characters/9-D-1.png +0 -0
- package/third_party/dependencies/README.md +0 -22
- package/third_party/dependencies/cargo-licenses.html +0 -7696
- package/third_party/dependencies/npm-licenses.txt +0 -1381
- package/third_party/licenses/Apache-2.0.txt +0 -190
- package/third_party/licenses/PixiJS-MIT.txt +0 -21
- package/vendor/herdr-compat/VENDOR-MANIFEST.toml +0 -186
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
import"./chunk-QTnfLwEv.js";import{$ as e,B as t,C as n,D as r,E as i,J as a,K as o,L as s,M as c,N as l,P as u,R as d,S as f,T as ee,U as te,W as ne,X as re,Y as ie,_ as p,a as m,at as ae,ct as h,dt as oe,et as g,ft as _,g as se,h as ce,i as le,it as ue,k as v,lt as de,m as fe,ot as y,pt as pe,rt as b,tt as x,ut as S,v as me,x as he,y as ge}from"./localUniformBit-BnogyqF-.js";var _e={name:`texture-bit`,vertex:{header:`
|
|
2
|
-
|
|
3
|
-
struct TextureUniforms {
|
|
4
|
-
uTextureMatrix:mat3x3<f32>,
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
@group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
|
|
8
|
-
`,main:`
|
|
9
|
-
uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
|
|
10
|
-
`},fragment:{header:`
|
|
11
|
-
@group(2) @binding(0) var uTexture: texture_2d<f32>;
|
|
12
|
-
@group(2) @binding(1) var uSampler: sampler;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`,main:`
|
|
16
|
-
outColor = textureSample(uTexture, uSampler, vUV);
|
|
17
|
-
`}},ve={name:`texture-bit`,vertex:{header:`
|
|
18
|
-
uniform mat3 uTextureMatrix;
|
|
19
|
-
`,main:`
|
|
20
|
-
uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
|
|
21
|
-
`},fragment:{header:`
|
|
22
|
-
uniform sampler2D uTexture;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
`,main:`
|
|
26
|
-
outColor = texture(uTexture, vUV);
|
|
27
|
-
`}},C=[];pe.handleByNamedList(_.Environment,C);async function ye(e){if(!e)for(let e=0;e<C.length;e++){let t=C[e];if(t.value.test()){await t.value.load();return}}}var w;function be(){if(typeof w==`boolean`)return w;try{w=Function(`param1`,`param2`,`param3`,`return param1[param2] === param3;`)({a:`b`},`a`,`b`)===!0}catch{w=!1}return w}var T=(e=>(e[e.NONE=0]=`NONE`,e[e.COLOR=16384]=`COLOR`,e[e.STENCIL=1024]=`STENCIL`,e[e.DEPTH=256]=`DEPTH`,e[e.COLOR_DEPTH=16640]=`COLOR_DEPTH`,e[e.COLOR_STENCIL=17408]=`COLOR_STENCIL`,e[e.DEPTH_STENCIL=1280]=`DEPTH_STENCIL`,e[e.ALL=17664]=`ALL`,e))(T||{}),xe=class{constructor(e){this.items=[],this._name=e}emit(e,t,n,r,i,a,o,s){let{name:c,items:l}=this;for(let u=0,d=l.length;u<d;u++)l[u][c](e,t,n,r,i,a,o,s);return this}add(e){return e[this._name]&&(this.remove(e),this.items.push(e)),this}remove(e){let t=this.items.indexOf(e);return t!==-1&&this.items.splice(t,1),this}contains(e){return this.items.indexOf(e)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}},Se=[`init`,`destroy`,`contextChange`,`resolutionChange`,`reset`,`renderEnd`,`renderStart`,`render`,`update`,`postrender`,`prerender`],Ce=class e extends oe{constructor(e){super(),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=e.type,this.name=e.name,this.config=e;let t=[...Se,...this.config.runners??[]];this._addRunners(...t),this._unsafeEvalCheck()}async init(t={}){await ye(t.skipExtensionImports===!0?!0:t.manageImports===!1),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(let e in this._systemsHash)t={...this._systemsHash[e].constructor.defaultOptions,...t};t={...e.defaultOptions,...t},this._roundPixels=+!!t.roundPixels;for(let e=0;e<this.runners.init.items.length;e++)await this.runners.init.items[e].init(t);this._initOptions=t}render(e,t){let n=e;if(n instanceof o&&(n={container:n},t&&(ue(ae,`passing a second argument is deprecated, please use render options instead`),n.target=t.renderTexture)),n.target||=this.view.renderTarget,n.target===this.view.renderTarget&&(this._lastObjectRendered=n.container,n.clearColor=this.background.colorRgba),n.clearColor){let e=Array.isArray(n.clearColor)&&n.clearColor.length===4;n.clearColor=e?n.clearColor:S.shared.setValue(n.clearColor).toArray()}n.transform||(n.container.updateLocalTransform(),n.transform=n.container.localTransform),this.runners.prerender.emit(n),this.runners.renderStart.emit(n),this.runners.render.emit(n),this.runners.renderEnd.emit(n),this.runners.postrender.emit(n)}resize(e,t,n){let r=this.view.resolution;this.view.resize(e,t,n),this.emit(`resize`,this.view.screen.width,this.view.screen.height,this.view.resolution),n!==void 0&&n!==r&&this.runners.resolutionChange.emit(n)}clear(e={}){let t=this;e.target||=t.renderTarget.renderTarget,e.clearColor||=this.background.colorRgba,e.clear??=T.ALL;let{clear:n,clearColor:r,target:i}=e;S.shared.setValue(r??this.background.colorRgba),t.renderTarget.clear(i,n,S.shared.toArray())}get resolution(){return this.view.resolution}set resolution(e){this.view.resolution=e,this.runners.resolutionChange.emit(e)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...e){e.forEach(e=>{this.runners[e]=new xe(e)})}_addSystems(e){let t;for(t in e){let n=e[t];this._addSystem(n.value,n.name)}}_addSystem(e,t){let n=new e(this);if(this[t])throw Error(`Whoops! The name "${t}" is already in use`);this[t]=n,this._systemsHash[t]=n;for(let e in this.runners)this.runners[e].add(n);return this}_addPipes(e,t){let n=t.reduce((e,t)=>(e[t.name]=t.value,e),{});e.forEach(e=>{let t=e.value,r=e.name,i=n[r];this.renderPipes[r]=new t(this,i?new i:null)})}destroy(e=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(e),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null}generateTexture(e){return this.textureGenerator.generateTexture(e)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!be())throw Error(`Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.`)}};Ce.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};var we=Ce,E=class{constructor(e){this._renderer=e}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){e.isRenderable&&e.render(this._renderer)}destroy(){this._renderer=null}};E.extension={type:[_.WebGLPipes,_.WebGPUPipes,_.CanvasPipes],name:`customRender`};function D(e,t){let n=e.instructionSet,r=n.instructions;for(let e=0;e<n.instructionSize;e++){let n=r[e];t[n.renderPipeId].execute(n)}}var O=class{constructor(e){this._renderer=e}addRenderGroup(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){e.isRenderable&&(this._renderer.globalUniforms.push({worldTransformMatrix:e.worldTransform,worldColor:e.worldColorAlpha}),D(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop())}destroy(){this._renderer=null}};O.extension={type:[_.WebGLPipes,_.WebGPUPipes,_.CanvasPipes],name:`renderGroup`};function Te(e,t){let n=e.root,r=e.instructionSet;r.reset();let i=t.renderPipes?t:t.batch.renderer,a=i.renderPipes;a.batch.buildStart(r),a.blendMode.buildStart(),a.colorMask.buildStart(),n.sortableChildren&&n.sortChildren(),A(n,r,i,!0),a.batch.buildEnd(r),a.blendMode.buildEnd(r)}function k(e,t,n){let r=n.renderPipes?n:n.batch.renderer;e.globalDisplayStatus<7||!e.includeInBuild||(e.sortableChildren&&e.sortChildren(),e.isSimple?Ee(e,t,r):A(e,t,r,!1))}function Ee(e,t,n){if(e.renderPipeId){let{renderPipes:r,renderableGC:i}=n;r.blendMode.setBlendMode(e,e.groupBlendMode,t),e.didViewUpdate=!1,r[e.renderPipeId].addRenderable(e,t),i.addRenderable(e,t)}if(!e.renderGroup){let r=e.children,i=r.length;for(let e=0;e<i;e++)k(r[e],t,n)}}function A(e,t,n,r){let{renderPipes:i,renderableGC:a}=n;if(!r&&e.renderGroup)i.renderGroup.addRenderGroup(e.renderGroup,t);else{for(let n=0;n<e.effects.length;n++){let r=e.effects[n];i[r.pipe].push(r,e,t)}let r=e.renderPipeId;r&&(i.blendMode.setBlendMode(e,e.groupBlendMode,t),e.didViewUpdate=!1,i[r].addRenderable(e,t),a.addRenderable(e,t));let o=e.children;if(o.length)for(let e=0;e<o.length;e++)k(o[e],t,n);for(let n=e.effects.length-1;n>=0;n--){let r=e.effects[n];i[r.pipe].pop(r,e,t)}}}function j(e,t){t||=0;for(let n=t;n<e.length&&e[n];n++)e[n]=null}function M(e,t=[]){t.push(e);for(let n=0;n<e.renderGroupChildren.length;n++)M(e.renderGroupChildren[n],t);return t}function De(e,t,n){let r=e>>16&255,i=e>>8&255,a=e&255,o=t>>16&255,s=t>>8&255,c=t&255,l=r+(o-r)*n,u=i+(s-i)*n,d=a+(c-a)*n;return(l<<16)+(u<<8)+d}var N=16777215;function P(e,t){return e===N||t===N?e+t-N:De(e,t,.5)}var Oe=new o,F=7;function I(e,t=!1){ke(e);let n=e.childrenToUpdate,r=e.updateTick++;for(let t in n){let i=Number(t),a=n[t],o=a.list,s=a.index;for(let t=0;t<s;t++){let n=o[t];n.parentRenderGroup===e&&n.relativeRenderGroupDepth===i&&L(n,r,0)}j(o,s),a.index=0}if(t)for(let n=0;n<e.renderGroupChildren.length;n++)I(e.renderGroupChildren[n],t)}function ke(e){let t=e.root,n;if(e.renderGroupParent){let r=e.renderGroupParent;e.worldTransform.appendFrom(t.relativeGroupTransform,r.worldTransform),e.worldColor=P(t.groupColor,r.worldColor),n=t.groupAlpha*r.worldAlpha}else e.worldTransform.copyFrom(t.localTransform),e.worldColor=t.localColor,n=t.localAlpha;n=n<0?0:n>1?1:n,e.worldAlpha=n,e.worldColorAlpha=e.worldColor+((n*255|0)<<24)}function L(e,t,n){if(t===e.updateTick)return;e.updateTick=t,e.didChange=!1;let r=e.localTransform;e.updateLocalTransform();let i=e.parent;if(i&&!i.renderGroup?(n|=e._updateFlags,e.relativeGroupTransform.appendFrom(r,i.relativeGroupTransform),n&F&&R(e,i,n)):(n=e._updateFlags,e.relativeGroupTransform.copyFrom(r),n&F&&R(e,Oe,n)),!e.renderGroup){let r=e.children,i=r.length;for(let e=0;e<i;e++)L(r[e],t,n);let a=e.parentRenderGroup;e.renderPipeId&&!a.structureDidChange&&a.updateRenderable(e)}}function R(e,t,n){if(n&1){e.groupColor=P(e.localColor,t.groupColor);let n=e.localAlpha*t.groupAlpha;n=n<0?0:n>1?1:n,e.groupAlpha=n,e.groupColorAlpha=e.groupColor+((n*255|0)<<24)}n&2&&(e.groupBlendMode=e.localBlendMode===`inherit`?t.groupBlendMode:e.localBlendMode),n&4&&(e.globalDisplayStatus=e.localDisplayStatus&t.globalDisplayStatus),e._updateFlags=0}function Ae(e,t){let{list:n,index:r}=e.childrenRenderablesToUpdate,i=!1;for(let e=0;e<r;e++){let r=n[e];if(i=t[r.renderPipeId].validateRenderable(r),i)break}return e.structureDidChange=i,i}var je=new h,z=class{constructor(e){this._renderer=e}render({container:e,transform:t}){e.isRenderGroup=!0;let n=e.parent,r=e.renderGroup.renderGroupParent;e.parent=null,e.renderGroup.renderGroupParent=null;let i=this._renderer,a=M(e.renderGroup,[]),o=je;t&&(o=o.copyFrom(e.renderGroup.localTransform),e.renderGroup.localTransform.copyFrom(t));let s=i.renderPipes;for(let e=0;e<a.length;e++){let t=a[e];t.runOnRender(),t.instructionSet.renderPipes=s,t.structureDidChange?j(t.childrenRenderablesToUpdate.list,0):Ae(t,s),I(t),t.structureDidChange?(t.structureDidChange=!1,Te(t,i)):Me(t),t.childrenRenderablesToUpdate.index=0,i.renderPipes.batch.upload(t.instructionSet)}i.globalUniforms.start({worldTransformMatrix:t?e.renderGroup.localTransform:e.renderGroup.worldTransform,worldColor:e.renderGroup.worldColorAlpha}),D(e.renderGroup,s),s.uniformBatch&&s.uniformBatch.renderEnd(),t&&e.renderGroup.localTransform.copyFrom(o),e.parent=n,e.renderGroup.renderGroupParent=r}destroy(){this._renderer=null}};z.extension={type:[_.WebGLSystem,_.WebGPUSystem,_.CanvasSystem],name:`renderGroup`};function Me(e){let{list:t,index:n}=e.childrenRenderablesToUpdate;for(let r=0;r<n;r++){let n=t[r];n.didViewUpdate&&e.updateRenderable(n)}j(t,n)}var Ne=class{constructor(e){this._gpuSpriteHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=e}addRenderable(e,t){let n=this._getGpuSprite(e);e._didSpriteUpdate&&this._updateBatchableSprite(e,n),this._renderer.renderPipes.batch.addToBatch(n)}updateRenderable(e){let t=this._gpuSpriteHash[e.uid];e._didSpriteUpdate&&this._updateBatchableSprite(e,t),t.batcher.updateElement(t)}validateRenderable(e){let t=e._texture,n=this._getGpuSprite(e);return n.texture._source===t._source?!1:!n.batcher.checkAndUpdateTexture(n,t)}destroyRenderable(e){let t=this._gpuSpriteHash[e.uid];b.return(t),this._gpuSpriteHash[e.uid]=null,e.off(`destroyed`,this._destroyRenderableBound)}_updateBatchableSprite(e,t){e._didSpriteUpdate=!1,t.bounds=e.bounds,t.texture=e._texture}_getGpuSprite(e){return this._gpuSpriteHash[e.uid]||this._initGPUSprite(e)}_initGPUSprite(e){let t=b.get(me);return t.renderable=e,t.texture=e._texture,t.bounds=e.bounds,t.roundPixels=this._renderer._roundPixels|e._roundPixels,this._gpuSpriteHash[e.uid]=t,e._didSpriteUpdate=!1,e.on(`destroyed`,this._destroyRenderableBound),t}destroy(){for(let e in this._gpuSpriteHash)b.return(this._gpuSpriteHash[e]);this._gpuSpriteHash=null,this._renderer=null}};Ne.extension={type:[_.WebGLPipes,_.WebGPUPipes,_.CanvasPipes],name:`sprite`};var B=class{static init(){globalThis.__PIXI_APP_INIT__?.(this)}static destroy(){}};B.extension=_.Application;var Pe=class{constructor(e){this._renderer=e}init(){globalThis.__PIXI_RENDERER_INIT__?.(this._renderer)}destroy(){this._renderer=null}};Pe.extension={type:[_.WebGLSystem,_.WebGPUSystem],name:`initHook`,priority:-10};var Fe=class{constructor(e,t){this.state=f.for2d(),this._batches=Object.create(null),this._geometries=Object.create(null),this.renderer=e,this._adaptor=t,this._adaptor.init(this)}buildStart(e){if(!this._batches[e.uid]){let t=new r;this._batches[e.uid]=t,this._geometries[t.uid]=new n}this._activeBatch=this._batches[e.uid],this._activeGeometry=this._geometries[this._activeBatch.uid],this._activeBatch.begin()}addToBatch(e){this._activeBatch.add(e)}break(e){this._activeBatch.break(e)}buildEnd(e){let t=this._activeBatch,n=this._activeGeometry;t.finish(e),n.indexBuffer.setDataWithSize(t.indexBuffer,t.indexSize,!0),n.buffers[0].setDataWithSize(t.attributeBuffer.float32View,t.attributeSize,!1)}upload(e){let t=this._batches[e.uid],n=this._geometries[t.uid];t.dirty&&(t.dirty=!1,n.buffers[0].update(t.attributeSize*4))}execute(e){if(e.action===`startBatch`){let t=e.batcher,n=this._geometries[t.uid];this._adaptor.start(this,n)}this._adaptor.execute(this,e)}destroy(){this.state=null,this.renderer=null,this._adaptor.destroy(),this._adaptor=null;for(let e in this._batches)this._batches[e].destroy();this._batches=null;for(let e in this._geometries)this._geometries[e].destroy();this._geometries=null}};Fe.extension={type:[_.WebGLPipes,_.WebGPUPipes,_.CanvasPipes],name:`batch`};var Ie=class e extends le{constructor(t){t={...e.defaultOptions,...t},super(t),this.enabled=!0,this._state=f.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias==`boolean`?this.antialias=t.antialias?`on`:`off`:this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.addResource(`uTexture`,0,1)}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(t){let{gpu:n,gl:r,...i}=t,a,o;return n&&(a=fe.from(n)),r&&(o=se.from(r)),new e({gpuProgram:a,glProgram:o,...i})}};Ie.defaultOptions={blendMode:`normal`,resolution:1,padding:0,antialias:`off`,blendRequired:!1};var Le=Ie,Re=`in vec2 vMaskCoord;
|
|
28
|
-
in vec2 vTextureCoord;
|
|
29
|
-
|
|
30
|
-
uniform sampler2D uTexture;
|
|
31
|
-
uniform sampler2D uMaskTexture;
|
|
32
|
-
|
|
33
|
-
uniform float uAlpha;
|
|
34
|
-
uniform vec4 uMaskClamp;
|
|
35
|
-
|
|
36
|
-
out vec4 finalColor;
|
|
37
|
-
|
|
38
|
-
void main(void)
|
|
39
|
-
{
|
|
40
|
-
float clip = step(3.5,
|
|
41
|
-
step(uMaskClamp.x, vMaskCoord.x) +
|
|
42
|
-
step(uMaskClamp.y, vMaskCoord.y) +
|
|
43
|
-
step(vMaskCoord.x, uMaskClamp.z) +
|
|
44
|
-
step(vMaskCoord.y, uMaskClamp.w));
|
|
45
|
-
|
|
46
|
-
// TODO look into why this is needed
|
|
47
|
-
float npmAlpha = uAlpha;
|
|
48
|
-
vec4 original = texture(uTexture, vTextureCoord);
|
|
49
|
-
vec4 masky = texture(uMaskTexture, vMaskCoord);
|
|
50
|
-
float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
|
|
51
|
-
|
|
52
|
-
original *= (alphaMul * masky.r * uAlpha * clip);
|
|
53
|
-
|
|
54
|
-
finalColor = original;
|
|
55
|
-
}
|
|
56
|
-
`,ze=`in vec2 aPosition;
|
|
57
|
-
|
|
58
|
-
out vec2 vTextureCoord;
|
|
59
|
-
out vec2 vMaskCoord;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
uniform vec4 uInputSize;
|
|
63
|
-
uniform vec4 uOutputFrame;
|
|
64
|
-
uniform vec4 uOutputTexture;
|
|
65
|
-
uniform mat3 uFilterMatrix;
|
|
66
|
-
|
|
67
|
-
vec4 filterVertexPosition( vec2 aPosition )
|
|
68
|
-
{
|
|
69
|
-
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
70
|
-
|
|
71
|
-
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
72
|
-
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
73
|
-
|
|
74
|
-
return vec4(position, 0.0, 1.0);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
vec2 filterTextureCoord( vec2 aPosition )
|
|
78
|
-
{
|
|
79
|
-
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
vec2 getFilterCoord( vec2 aPosition )
|
|
83
|
-
{
|
|
84
|
-
return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
void main(void)
|
|
88
|
-
{
|
|
89
|
-
gl_Position = filterVertexPosition(aPosition);
|
|
90
|
-
vTextureCoord = filterTextureCoord(aPosition);
|
|
91
|
-
vMaskCoord = getFilterCoord(aPosition);
|
|
92
|
-
}
|
|
93
|
-
`,Be=`struct GlobalFilterUniforms {
|
|
94
|
-
uInputSize:vec4<f32>,
|
|
95
|
-
uInputPixel:vec4<f32>,
|
|
96
|
-
uInputClamp:vec4<f32>,
|
|
97
|
-
uOutputFrame:vec4<f32>,
|
|
98
|
-
uGlobalFrame:vec4<f32>,
|
|
99
|
-
uOutputTexture:vec4<f32>,
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
struct MaskUniforms {
|
|
103
|
-
uFilterMatrix:mat3x3<f32>,
|
|
104
|
-
uMaskClamp:vec4<f32>,
|
|
105
|
-
uAlpha:f32,
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
110
|
-
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
111
|
-
@group(0) @binding(2) var uSampler : sampler;
|
|
112
|
-
|
|
113
|
-
@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
|
|
114
|
-
@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
|
|
115
|
-
|
|
116
|
-
struct VSOutput {
|
|
117
|
-
@builtin(position) position: vec4<f32>,
|
|
118
|
-
@location(0) uv : vec2<f32>,
|
|
119
|
-
@location(1) filterUv : vec2<f32>,
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
123
|
-
{
|
|
124
|
-
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
125
|
-
|
|
126
|
-
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
127
|
-
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
128
|
-
|
|
129
|
-
return vec4(position, 0.0, 1.0);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
133
|
-
{
|
|
134
|
-
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
138
|
-
{
|
|
139
|
-
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
|
|
143
|
-
{
|
|
144
|
-
return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
fn getSize() -> vec2<f32>
|
|
148
|
-
{
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return gfu.uGlobalFrame.zw;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
@vertex
|
|
155
|
-
fn mainVertex(
|
|
156
|
-
@location(0) aPosition : vec2<f32>,
|
|
157
|
-
) -> VSOutput {
|
|
158
|
-
return VSOutput(
|
|
159
|
-
filterVertexPosition(aPosition),
|
|
160
|
-
filterTextureCoord(aPosition),
|
|
161
|
-
getFilterCoord(aPosition)
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
@fragment
|
|
166
|
-
fn mainFragment(
|
|
167
|
-
@location(0) uv: vec2<f32>,
|
|
168
|
-
@location(1) filterUv: vec2<f32>,
|
|
169
|
-
@builtin(position) position: vec4<f32>
|
|
170
|
-
) -> @location(0) vec4<f32> {
|
|
171
|
-
|
|
172
|
-
var maskClamp = filterUniforms.uMaskClamp;
|
|
173
|
-
|
|
174
|
-
var clip = step(3.5,
|
|
175
|
-
step(maskClamp.x, filterUv.x) +
|
|
176
|
-
step(maskClamp.y, filterUv.y) +
|
|
177
|
-
step(filterUv.x, maskClamp.z) +
|
|
178
|
-
step(filterUv.y, maskClamp.w));
|
|
179
|
-
|
|
180
|
-
var mask = textureSample(uMaskTexture, uSampler, filterUv);
|
|
181
|
-
var source = textureSample(uTexture, uSampler, uv);
|
|
182
|
-
|
|
183
|
-
var npmAlpha = 0.0;
|
|
184
|
-
|
|
185
|
-
var alphaMul = 1.0 - npmAlpha * (1.0 - mask.a);
|
|
186
|
-
|
|
187
|
-
var a = (alphaMul * mask.r) * clip;
|
|
188
|
-
|
|
189
|
-
return vec4(source.rgb, source.a) * a;
|
|
190
|
-
}`,Ve=class extends Le{constructor(e){let{sprite:t,...n}=e,r=new d(t.texture),i=new ge({uFilterMatrix:{value:new h,type:`mat3x3<f32>`},uMaskClamp:{value:r.uClampFrame,type:`vec4<f32>`},uAlpha:{value:1,type:`f32`}}),a=fe.from({vertex:{source:Be,entryPoint:`mainVertex`},fragment:{source:Be,entryPoint:`mainFragment`}}),o=se.from({vertex:ze,fragment:Re,name:`mask-filter`});super({...n,gpuProgram:a,glProgram:o,resources:{filterUniforms:i,uMaskTexture:t.texture.source}}),this.sprite=t,this._textureMatrix=r}apply(e,t,n,r){this._textureMatrix.texture=this.sprite.texture,e.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,e.applyFilter(this,t,n,r)}},He=new e,Ue=class extends x{constructor(){super(),this.filters=[new Ve({sprite:new u(s.EMPTY),resolution:`inherit`,antialias:`inherit`})]}get sprite(){return this.filters[0].sprite}set sprite(e){this.filters[0].sprite=e}},We=class{constructor(e){this._activeMaskStage=[],this._renderer=e}push(e,t,n){let r=this._renderer;if(r.renderPipes.batch.break(n),n.add({renderPipeId:`alphaMask`,action:`pushMaskBegin`,mask:e,canBundle:!1,maskedContainer:t}),e.renderMaskToTexture){let t=e.mask;t.includeInBuild=!0,k(t,n,r),t.includeInBuild=!1}r.renderPipes.batch.break(n),n.add({renderPipeId:`alphaMask`,action:`pushMaskEnd`,mask:e,maskedContainer:t,canBundle:!1})}pop(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:`alphaMask`,action:`popMaskEnd`,mask:e,canBundle:!1})}execute(e){let t=this._renderer,n=e.mask.renderMaskToTexture;if(e.action===`pushMaskBegin`){let r=b.get(Ue);if(n){e.mask.mask.measurable=!0;let n=re(e.mask.mask,!0,He);e.mask.mask.measurable=!1,n.ceil();let i=t.renderTarget.renderTarget.colorTexture.source,a=p.getOptimalTexture(n.width,n.height,i._resolution,i.antialias);t.renderTarget.push(a,!0),t.globalUniforms.push({offset:n,worldColor:4294967295});let o=r.sprite;o.texture=a,o.worldTransform.tx=n.minX,o.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:r,maskedContainer:e.maskedContainer,filterTexture:a})}else r.sprite=e.mask.mask,this._activeMaskStage.push({filterEffect:r,maskedContainer:e.maskedContainer})}else if(e.action===`pushMaskEnd`){let e=this._activeMaskStage[this._activeMaskStage.length-1];n&&(t.type===m.WEBGL&&t.renderTarget.finishRenderPass(),t.renderTarget.pop(),t.globalUniforms.pop()),t.filter.push({renderPipeId:`filter`,action:`pushFilter`,container:e.maskedContainer,filterEffect:e.filterEffect,canBundle:!1})}else if(e.action===`popMaskEnd`){t.filter.pop();let e=this._activeMaskStage.pop();n&&p.returnTexture(e.filterTexture),b.return(e.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}};We.extension={type:[_.WebGLPipes,_.WebGPUPipes,_.CanvasPipes],name:`alphaMask`};var Ge=class{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,n){this._renderer.renderPipes.batch.break(n);let r=this._colorStack;r[this._colorStackIndex]=r[this._colorStackIndex-1]&e.mask;let i=this._colorStack[this._colorStackIndex];i!==this._currentColor&&(this._currentColor=i,n.add({renderPipeId:`colorMask`,colorMask:i,canBundle:!1})),this._colorStackIndex++}pop(e,t,n){this._renderer.renderPipes.batch.break(n);let r=this._colorStack;this._colorStackIndex--;let i=r[this._colorStackIndex-1];i!==this._currentColor&&(this._currentColor=i,n.add({renderPipeId:`colorMask`,colorMask:i,canBundle:!1}))}execute(e){this._renderer.colorMask.setMask(e.colorMask)}destroy(){this._colorStack=null}};Ge.extension={type:[_.WebGLPipes,_.WebGPUPipes,_.CanvasPipes],name:`colorMask`};var Ke=class{constructor(e){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=e}push(e,t,n){var r;let i=e,a=this._renderer;a.renderPipes.batch.break(n),a.renderPipes.blendMode.setBlendMode(i.mask,`none`,n),n.add({renderPipeId:`stencilMask`,action:`pushMaskBegin`,mask:e,canBundle:!1});let o=i.mask;o.includeInBuild=!0,this._maskHash.has(i)||this._maskHash.set(i,{instructionsStart:0,instructionsLength:0});let s=this._maskHash.get(i);s.instructionsStart=n.instructionSize,k(o,n,a),o.includeInBuild=!1,a.renderPipes.batch.break(n),n.add({renderPipeId:`stencilMask`,action:`pushMaskEnd`,mask:e,canBundle:!1}),s.instructionsLength=n.instructionSize-s.instructionsStart-1;let c=a.renderTarget.renderTarget.uid;(r=this._maskStackHash)[c]??(r[c]=0)}pop(e,t,n){let r=e,i=this._renderer;i.renderPipes.batch.break(n),i.renderPipes.blendMode.setBlendMode(r.mask,`none`,n),n.add({renderPipeId:`stencilMask`,action:`popMaskBegin`,canBundle:!1});let a=this._maskHash.get(e);for(let e=0;e<a.instructionsLength;e++)n.instructions[n.instructionSize++]=n.instructions[a.instructionsStart++];n.add({renderPipeId:`stencilMask`,action:`popMaskEnd`,canBundle:!1})}execute(e){var t;let n=this._renderer,r=n.renderTarget.renderTarget.uid,i=(t=this._maskStackHash)[r]??(t[r]=0);e.action===`pushMaskBegin`?(n.renderTarget.ensureDepthStencil(),n.stencil.setStencilMode(v.RENDERING_MASK_ADD,i),i++,n.colorMask.setMask(0)):e.action===`pushMaskEnd`?(n.stencil.setStencilMode(v.MASK_ACTIVE,i),n.colorMask.setMask(15)):e.action===`popMaskBegin`?(n.colorMask.setMask(0),i===0?(n.renderTarget.clear(null,T.STENCIL),n.stencil.setStencilMode(v.DISABLED,i)):n.stencil.setStencilMode(v.RENDERING_MASK_REMOVE,i),i--):e.action===`popMaskEnd`&&(n.stencil.setStencilMode(v.MASK_ACTIVE,i),n.colorMask.setMask(15)),this._maskStackHash[r]=i}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}};Ke.extension={type:[_.WebGLPipes,_.WebGPUPipes,_.CanvasPipes],name:`stencilMask`};var V=class e{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new S(0),this.color=this._backgroundColor,this.alpha=1}init(t){t={...e.defaultOptions,...t},this.clearBeforeRender=t.clearBeforeRender,this.color=t.background||t.backgroundColor||this._backgroundColor,this.alpha=t.backgroundAlpha,this._backgroundColor.setAlpha(t.backgroundAlpha)}get color(){return this._backgroundColor}set color(e){this._backgroundColor.setValue(e)}get alpha(){return this._backgroundColor.alpha}set alpha(e){this._backgroundColor.setAlpha(e)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};V.extension={type:[_.WebGLSystem,_.WebGPUSystem,_.CanvasSystem],name:`background`,priority:0},V.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};var qe=V,H={};pe.handle(_.BlendMode,e=>{if(!e.name)throw Error(`BlendMode extension must have a name property`);H[e.name]=e.ref},e=>{delete H[e.name]});var Je=class{constructor(e){this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=e}setBlendMode(e,t,n){if(this._activeBlendMode===t){this._isAdvanced&&this._renderableList.push(e);return}this._activeBlendMode=t,this._isAdvanced&&this._endAdvancedBlendMode(n),this._isAdvanced=!!H[t],this._isAdvanced&&(this._beginAdvancedBlendMode(n),this._renderableList.push(e))}_beginAdvancedBlendMode(e){this._renderer.renderPipes.batch.break(e);let t=this._activeBlendMode;if(!H[t]){ie(`Unable to assign BlendMode: '${t}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}let n=this._filterHash[t];n||(n=this._filterHash[t]=new x,n.filters=[new H[t]]);let r={renderPipeId:`filter`,action:`pushFilter`,renderables:[],filterEffect:n,canBundle:!1};this._renderableList=r.renderables,e.add(r)}_endAdvancedBlendMode(e){this._renderableList=null,this._renderer.renderPipes.batch.break(e),e.add({renderPipeId:`filter`,action:`popFilter`,canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(e){this._isAdvanced&&this._endAdvancedBlendMode(e)}destroy(){this._renderer=null,this._renderableList=null;for(let e in this._filterHash)this._filterHash[e].destroy();this._filterHash=null}};Je.extension={type:[_.WebGLPipes,_.WebGPUPipes,_.CanvasPipes],name:`blendMode`};var U={png:`image/png`,jpg:`image/jpeg`,webp:`image/webp`},W=class e{constructor(e){this._renderer=e}_normalizeOptions(e,t={}){return e instanceof o||e instanceof s?{target:e,...t}:{...t,...e}}async image(e){let t=new Image;return t.src=await this.base64(e),t}async base64(t){t=this._normalizeOptions(t,e.defaultImageOptions);let{format:n,quality:r}=t,i=this.canvas(t);if(i.toBlob!==void 0)return new Promise((e,t)=>{i.toBlob(n=>{if(!n){t(Error(`ICanvas.toBlob failed!`));return}let r=new FileReader;r.onload=()=>e(r.result),r.onerror=t,r.readAsDataURL(n)},U[n],r)});if(i.toDataURL!==void 0)return i.toDataURL(U[n],r);if(i.convertToBlob!==void 0){let e=await i.convertToBlob({type:U[n],quality:r});return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}throw Error(`Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented`)}canvas(e){e=this._normalizeOptions(e);let t=e.target,n=this._renderer;if(t instanceof s)return n.texture.generateCanvas(t);let r=n.textureGenerator.generateTexture(e),i=n.texture.generateCanvas(r);return r.destroy(),i}pixels(e){e=this._normalizeOptions(e);let t=e.target,n=this._renderer,r=t instanceof s?t:n.textureGenerator.generateTexture(e),i=n.texture.getPixels(r);return t instanceof o&&r.destroy(),i}texture(e){return e=this._normalizeOptions(e),e.target instanceof s?e.target:this._renderer.textureGenerator.generateTexture(e)}download(e){e=this._normalizeOptions(e);let t=this.canvas(e),n=document.createElement(`a`);n.download=e.filename??`image.png`,n.href=t.toDataURL(`image/png`),document.body.appendChild(n),n.click(),document.body.removeChild(n)}log(e){let t=e.width??200;e=this._normalizeOptions(e);let n=this.canvas(e),r=n.toDataURL();console.log(`[Pixi Texture] ${n.width}px ${n.height}px`);let i=[`font-size: 1px;`,`padding: ${t}px 300px;`,`background: url(${r}) no-repeat;`,`background-size: contain;`].join(` `);console.log(`%c `,i)}destroy(){this._renderer=null}};W.extension={type:[_.WebGLSystem,_.WebGPUSystem],name:`extract`},W.defaultImageOptions={format:`png`,quality:1};var Ye=W,Xe=class e extends s{static create(n){return new e({source:new t(n)})}resize(e,t,n){return this.source.resize(e,t,n),this}},Ze=new g,Qe=new e,$e=[0,0,0,0],et=class{constructor(e){this._renderer=e}generateTexture(e){e instanceof o&&(e={target:e,frame:void 0,textureSourceOptions:{},resolution:void 0});let t=e.resolution||this._renderer.resolution,n=e.antialias||this._renderer.view.antialias,r=e.target,i=e.clearColor;i=i?Array.isArray(i)&&i.length===4?i:S.shared.setValue(i).toArray():$e;let s=e.frame?.copyTo(Ze)||a(r,Qe).rectangle;s.width=Math.max(s.width,1/t)|0,s.height=Math.max(s.height,1/t)|0;let c=Xe.create({...e.textureSourceOptions,width:s.width,height:s.height,resolution:t,antialias:n}),l=h.shared.translate(-s.x,-s.y);return this._renderer.render({container:r,transform:l,target:c,clearColor:i}),c.source.updateMipmaps(),c}destroy(){this._renderer=null}};et.extension={type:[_.WebGLSystem,_.WebGPUSystem],name:`textureGenerator`};var tt=class{constructor(e){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=e}reset(){this._stackIndex=0;for(let e=0;e<this._activeUniforms.length;e++)this._uniformsPool.push(this._activeUniforms[e]);for(let e=0;e<this._activeBindGroups.length;e++)this._bindGroupPool.push(this._activeBindGroups[e]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(e){this.reset(),this.push(e)}bind({size:e,projectionMatrix:t,worldTransformMatrix:n,worldColor:r,offset:i}){let a=this._renderer.renderTarget.renderTarget,o=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:a,worldTransformMatrix:new h,worldColor:4294967295,offset:new de},s={projectionMatrix:t||this._renderer.renderTarget.projectionMatrix,resolution:e||a.size,worldTransformMatrix:n||o.worldTransformMatrix,worldColor:r||o.worldColor,offset:i||o.offset,bindGroup:null},l=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(l);let u=l.uniforms;u.uProjectionMatrix=s.projectionMatrix,u.uResolution=s.resolution,u.uWorldTransformMatrix.copyFrom(s.worldTransformMatrix),u.uWorldTransformMatrix.tx-=s.offset.x,u.uWorldTransformMatrix.ty-=s.offset.y,he(s.worldColor,u.uWorldColorAlpha,0),l.update();let d;this._renderer.renderPipes.uniformBatch?d=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(l,!1):(d=this._bindGroupPool.pop()||new c,this._activeBindGroups.push(d),d.setResource(l,0)),s.bindGroup=d,this._currentGlobalUniformData=s}push(e){this.bind(e),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===m.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new ge({uProjectionMatrix:{value:new h,type:`mat3x3<f32>`},uWorldTransformMatrix:{value:new h,type:`mat3x3<f32>`},uWorldColorAlpha:{value:new Float32Array(4),type:`vec4<f32>`},uResolution:{value:[0,0],type:`vec2<f32>`}},{isStatic:!0})}destroy(){this._renderer=null}};tt.extension={type:[_.WebGLSystem,_.WebGPUSystem,_.CanvasSystem],name:`globalUniforms`};var nt=1,rt=class{constructor(){this._tasks=[]}init(){ne.system.add(this._update,this)}repeat(e,t){let n=nt++;return this._tasks.push({func:e,duration:t,start:performance.now(),last:performance.now(),repeat:!0,id:n}),n}cancel(e){for(let t=0;t<this._tasks.length;t++)if(this._tasks[t].id===e){this._tasks.splice(t,1);return}}_update(){let e=performance.now();for(let t=0;t<this._tasks.length;t++){let n=this._tasks[t];if(e-n.last>=n.duration){let t=e-n.start;n.func(t),n.last=e}}}destroy(){ne.system.remove(this._update,this),this._tasks.length=0}};rt.extension={type:[_.WebGLSystem,_.WebGPUSystem,_.CanvasSystem],name:`scheduler`,priority:0};var it=!1,at=`8.3.4`;function ot(e){if(!it){if(te.get().getNavigator().userAgent.toLowerCase().indexOf(`chrome`)>-1){let t=[`%c %c %c %c %c PixiJS %c v${at} (${e}) http://www.pixijs.com/
|
|
191
|
-
|
|
192
|
-
`,`background: #E72264; padding:5px 0;`,`background: #6CA2EA; padding:5px 0;`,`background: #B5D33D; padding:5px 0;`,`background: #FED23F; padding:5px 0;`,`color: #FFFFFF; background: #E72264; padding:5px 0;`,`color: #E72264; background: #FFFFFF; padding:5px 0;`];globalThis.console.log(...t)}else globalThis.console&&globalThis.console.log(`PixiJS ${at} - ${e} - http://www.pixijs.com/`);it=!0}}var G=class{constructor(e){this._renderer=e}init(e){if(e.hello){let e=this._renderer.name;this._renderer.type===m.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),ot(e)}}};G.extension={type:[_.WebGLSystem,_.WebGPUSystem,_.CanvasSystem],name:`hello`,priority:-2},G.defaultOptions={hello:!1};var K=class e{constructor(e){this._managedRenderables=[],this._renderer=e}init(t){t={...e.defaultOptions,...t},this.maxUnusedTime=t.renderableGCMaxUnusedTime,this._frequency=t.renderableGCFrequency,this.enabled=t.renderableGCActive}get enabled(){return!!this._handler}set enabled(e){this.enabled!==e&&(e?this._handler=this._renderer.scheduler.repeat(()=>this.run(),this._frequency):this._renderer.scheduler.cancel(this._handler))}prerender(){this._now=performance.now()}addRenderable(e,t){this.enabled&&(e._lastUsed=this._now,e._lastInstructionTick===-1&&(this._managedRenderables.push(e),e.once(`destroyed`,this._removeRenderable,this)),e._lastInstructionTick=t.tick)}run(){let e=performance.now(),t=this._managedRenderables,n=this._renderer.renderPipes,r=0;for(let i=0;i<t.length;i++){let a=t[i];if(a===null){r++;continue}let o=(a.renderGroup??a.parentRenderGroup)?.instructionSet?.tick??-1;a._lastInstructionTick!==o&&e-a._lastUsed>this.maxUnusedTime?(a.destroyed||n[a.renderPipeId].destroyRenderable(a),a._lastInstructionTick=-1,r++,a.off(`destroyed`,this._removeRenderable,this)):t[i-r]=a}t.length-=r}destroy(){this.enabled=!1,this._renderer=null,this._managedRenderables.length=0}_removeRenderable(e){let t=this._managedRenderables.indexOf(e);t>=0&&(e.off(`destroyed`,this._removeRenderable,this),this._managedRenderables[t]=null)}};K.extension={type:[_.WebGLSystem,_.WebGPUSystem],name:`renderableGC`},K.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};var st=K,q=class e{constructor(e){this._renderer=e,this.count=0,this.checkCount=0}init(t){t={...e.defaultOptions,...t},this.checkCountMax=t.textureGCCheckCountMax,this.maxIdle=t.textureGCAMaxIdle??t.textureGCMaxIdle,this.active=t.textureGCActive}postrender(){this._renderer.renderingToScreen&&(this.count++,this.active&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){let e=this._renderer.texture.managedTextures;for(let t=0;t<e.length;t++){let n=e[t];n.autoGarbageCollect&&n.resource&&n._touched>-1&&this.count-n._touched>this.maxIdle&&(n._touched=-1,n.unload())}}destroy(){this._renderer=null}};q.extension={type:[_.WebGLSystem,_.WebGPUSystem],name:`textureGC`},q.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};var ct=q,lt=class e{constructor(n={}){if(this.uid=y(`renderTarget`),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,n={...e.defaultOptions,...n},this.stencil=n.stencil,this.depth=n.depth,this.isRoot=n.isRoot,typeof n.colorTextures==`number`){this._managedColorTextures=!0;for(let e=0;e<n.colorTextures;e++)this.colorTextures.push(new t({width:n.width,height:n.height,resolution:n.resolution,antialias:n.antialias}))}else{this.colorTextures=[...n.colorTextures.map(e=>e.source)];let e=this.colorTexture.source;this.resize(e.width,e.height,e._resolution)}this.colorTexture.source.on(`resize`,this.onSourceResize,this),(n.depthStencilTexture||this.stencil)&&(n.depthStencilTexture instanceof s||n.depthStencilTexture instanceof t?this.depthStencilTexture=n.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){let e=this._size;return e[0]=this.pixelWidth,e[1]=this.pixelHeight,e}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(e){this.resize(e.width,e.height,e._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||=new t({width:this.width,height:this.height,resolution:this.resolution,format:`depth24plus-stencil8`,autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1})}resize(e,t,n=this.resolution,r=!1){this.dirtyId++,this.colorTextures.forEach((i,a)=>{r&&a===0||i.source.resize(e,t,n)}),this.depthStencilTexture&&this.depthStencilTexture.source.resize(e,t,n)}destroy(){this.colorTexture.source.off(`resize`,this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach(e=>{e.destroy()}),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};lt.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};var J=lt,Y=new Map;function ut(e,t){if(!Y.has(e)){let n=new s({source:new l({resource:e,...t})}),r=()=>{Y.get(e)===n&&Y.delete(e)};n.once(`destroy`,r),n.source.once(`destroy`,r),Y.set(e,n)}return Y.get(e)}var X=class e{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(e){this.texture.source.autoDensity=e}get resolution(){return this.texture.source._resolution}set resolution(e){this.texture.source.resize(this.texture.source.width,this.texture.source.height,e)}init(t){t={...e.defaultOptions,...t},t.view&&(ue(ae,`ViewSystem.view has been renamed to ViewSystem.canvas`),t.canvas=t.view),this.screen=new g(0,0,t.width,t.height),this.canvas=t.canvas||te.get().createCanvas(),this.antialias=!!t.antialias,this.texture=ut(this.canvas,t),this.renderTarget=new J({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.multiView=!!t.multiView,this.resolution=t.resolution}resize(e,t,n){this.texture.source.resize(e,t,n),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(e=!1){(typeof e==`boolean`?e:e?.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}};X.extension={type:[_.WebGLSystem,_.WebGPUSystem,_.CanvasSystem],name:`view`,priority:0},X.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};var dt=[qe,tt,G,X,z,ct,et,Ye,Pe,st,rt],ft=[Je,Fe,Ne,O,We,Ke,Ge,E];function pt(e,t){for(let n in e.attributes){let r=e.attributes[n],i=t[n];i?(r.format??=i.format,r.offset??=i.offset,r.instance??=i.instance):ie(`Attribute ${n} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}mt(e)}function mt(e){let{buffers:t,attributes:n}=e,r={},i={};for(let e in t){let n=t[e];r[n.uid]=0,i[n.uid]=0}for(let e in n){let t=n[e];r[t.buffer.uid]+=ce(t.format).stride}for(let e in n){let t=n[e];t.stride??=r[t.buffer.uid],t.start??=i[t.buffer.uid],i[t.buffer.uid]+=ce(t.format).stride}}var Z=[];Z[v.NONE]=void 0,Z[v.DISABLED]={stencilWriteMask:0,stencilReadMask:0},Z[v.RENDERING_MASK_ADD]={stencilFront:{compare:`equal`,passOp:`increment-clamp`},stencilBack:{compare:`equal`,passOp:`increment-clamp`}},Z[v.RENDERING_MASK_REMOVE]={stencilFront:{compare:`equal`,passOp:`decrement-clamp`},stencilBack:{compare:`equal`,passOp:`decrement-clamp`}},Z[v.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:`equal`,passOp:`keep`},stencilBack:{compare:`equal`,passOp:`keep`}};var ht=class{constructor(e){this._syncFunctionHash=Object.create(null),this._adaptor=e,this._systemCheck()}_systemCheck(){if(!be())throw Error(`Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.`)}ensureUniformGroup(e){let t=this.getUniformGroupData(e);e.buffer||=new ee({data:new Float32Array(t.layout.size/4),usage:i.UNIFORM|i.COPY_DST})}getUniformGroupData(e){return this._syncFunctionHash[e._signature]||this._initUniformGroup(e)}_initUniformGroup(e){let t=e._signature,n=this._syncFunctionHash[t];if(!n){let r=Object.keys(e.uniformStructures).map(t=>e.uniformStructures[t]),i=this._adaptor.createUboElements(r),a=this._generateUboSync(i.uboElements);n=this._syncFunctionHash[t]={layout:i,syncFunction:a}}return this._syncFunctionHash[t]}_generateUboSync(e){return this._adaptor.generateUboSync(e)}syncUniformGroup(e,t,n){let r=this.getUniformGroupData(e);return e.buffer||=new ee({data:new Float32Array(r.layout.size/4),usage:i.UNIFORM|i.COPY_DST}),t||=e.buffer.data,n||=0,r.syncFunction(e.uniforms,t,n),!0}updateUniformGroup(e){if(e.isStatic&&!e._dirtyId)return!1;e._dirtyId=0;let t=this.syncUniformGroup(e);return e.buffer.update(),t}destroy(){this._syncFunctionHash=null}},Q=[{type:`mat3x3<f32>`,test:e=>e.value.a!==void 0,ubo:`
|
|
193
|
-
var matrix = uv[name].toArray(true);
|
|
194
|
-
data[offset] = matrix[0];
|
|
195
|
-
data[offset + 1] = matrix[1];
|
|
196
|
-
data[offset + 2] = matrix[2];
|
|
197
|
-
data[offset + 4] = matrix[3];
|
|
198
|
-
data[offset + 5] = matrix[4];
|
|
199
|
-
data[offset + 6] = matrix[5];
|
|
200
|
-
data[offset + 8] = matrix[6];
|
|
201
|
-
data[offset + 9] = matrix[7];
|
|
202
|
-
data[offset + 10] = matrix[8];
|
|
203
|
-
`,uniform:`
|
|
204
|
-
gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
|
|
205
|
-
`},{type:`vec4<f32>`,test:e=>e.type===`vec4<f32>`&&e.size===1&&e.value.width!==void 0,ubo:`
|
|
206
|
-
v = uv[name];
|
|
207
|
-
data[offset] = v.x;
|
|
208
|
-
data[offset + 1] = v.y;
|
|
209
|
-
data[offset + 2] = v.width;
|
|
210
|
-
data[offset + 3] = v.height;
|
|
211
|
-
`,uniform:`
|
|
212
|
-
cv = ud[name].value;
|
|
213
|
-
v = uv[name];
|
|
214
|
-
if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
|
|
215
|
-
cv[0] = v.x;
|
|
216
|
-
cv[1] = v.y;
|
|
217
|
-
cv[2] = v.width;
|
|
218
|
-
cv[3] = v.height;
|
|
219
|
-
gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
|
|
220
|
-
}
|
|
221
|
-
`},{type:`vec2<f32>`,test:e=>e.type===`vec2<f32>`&&e.size===1&&e.value.x!==void 0,ubo:`
|
|
222
|
-
v = uv[name];
|
|
223
|
-
data[offset] = v.x;
|
|
224
|
-
data[offset + 1] = v.y;
|
|
225
|
-
`,uniform:`
|
|
226
|
-
cv = ud[name].value;
|
|
227
|
-
v = uv[name];
|
|
228
|
-
if (cv[0] !== v.x || cv[1] !== v.y) {
|
|
229
|
-
cv[0] = v.x;
|
|
230
|
-
cv[1] = v.y;
|
|
231
|
-
gl.uniform2f(ud[name].location, v.x, v.y);
|
|
232
|
-
}
|
|
233
|
-
`},{type:`vec4<f32>`,test:e=>e.type===`vec4<f32>`&&e.size===1&&e.value.red!==void 0,ubo:`
|
|
234
|
-
v = uv[name];
|
|
235
|
-
data[offset] = v.red;
|
|
236
|
-
data[offset + 1] = v.green;
|
|
237
|
-
data[offset + 2] = v.blue;
|
|
238
|
-
data[offset + 3] = v.alpha;
|
|
239
|
-
`,uniform:`
|
|
240
|
-
cv = ud[name].value;
|
|
241
|
-
v = uv[name];
|
|
242
|
-
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
|
|
243
|
-
cv[0] = v.red;
|
|
244
|
-
cv[1] = v.green;
|
|
245
|
-
cv[2] = v.blue;
|
|
246
|
-
cv[3] = v.alpha;
|
|
247
|
-
gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
|
|
248
|
-
}
|
|
249
|
-
`},{type:`vec3<f32>`,test:e=>e.type===`vec3<f32>`&&e.size===1&&e.value.red!==void 0,ubo:`
|
|
250
|
-
v = uv[name];
|
|
251
|
-
data[offset] = v.red;
|
|
252
|
-
data[offset + 1] = v.green;
|
|
253
|
-
data[offset + 2] = v.blue;
|
|
254
|
-
`,uniform:`
|
|
255
|
-
cv = ud[name].value;
|
|
256
|
-
v = uv[name];
|
|
257
|
-
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
|
|
258
|
-
cv[0] = v.red;
|
|
259
|
-
cv[1] = v.green;
|
|
260
|
-
cv[2] = v.blue;
|
|
261
|
-
gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
|
|
262
|
-
}
|
|
263
|
-
`}];function gt(e,t,n,r){let i=[`
|
|
264
|
-
var v = null;
|
|
265
|
-
var v2 = null;
|
|
266
|
-
var t = 0;
|
|
267
|
-
var index = 0;
|
|
268
|
-
var name = null;
|
|
269
|
-
var arrayOffset = null;
|
|
270
|
-
`],a=0;for(let o=0;o<e.length;o++){let s=e[o],c=s.data.name,l=!1,u=0;for(let e=0;e<Q.length;e++)if(Q[e].test(s.data)){u=s.offset/4,i.push(`name = "${c}";`,`offset += ${u-a};`,Q[e][t]||Q[e].ubo),l=!0;break}if(!l)if(s.data.size>1)u=s.offset/4,i.push(n(s,u-a));else{let e=r[s.data.type];u=s.offset/4,i.push(`
|
|
271
|
-
v = uv.${c};
|
|
272
|
-
offset += ${u-a};
|
|
273
|
-
${e};
|
|
274
|
-
`)}a=u}let o=i.join(`
|
|
275
|
-
`);return Function(`uv`,`data`,`offset`,o)}function $(e,t){return`
|
|
276
|
-
for (let i = 0; i < ${e*t}; i++) {
|
|
277
|
-
data[offset + (((i / ${e})|0) * 4) + (i % ${e})] = v[i];
|
|
278
|
-
}
|
|
279
|
-
`}var _t={f32:`
|
|
280
|
-
data[offset] = v;`,i32:`
|
|
281
|
-
data[offset] = v;`,"vec2<f32>":`
|
|
282
|
-
data[offset] = v[0];
|
|
283
|
-
data[offset + 1] = v[1];`,"vec3<f32>":`
|
|
284
|
-
data[offset] = v[0];
|
|
285
|
-
data[offset + 1] = v[1];
|
|
286
|
-
data[offset + 2] = v[2];`,"vec4<f32>":`
|
|
287
|
-
data[offset] = v[0];
|
|
288
|
-
data[offset + 1] = v[1];
|
|
289
|
-
data[offset + 2] = v[2];
|
|
290
|
-
data[offset + 3] = v[3];`,"mat2x2<f32>":`
|
|
291
|
-
data[offset] = v[0];
|
|
292
|
-
data[offset + 1] = v[1];
|
|
293
|
-
data[offset + 4] = v[2];
|
|
294
|
-
data[offset + 5] = v[3];`,"mat3x3<f32>":`
|
|
295
|
-
data[offset] = v[0];
|
|
296
|
-
data[offset + 1] = v[1];
|
|
297
|
-
data[offset + 2] = v[2];
|
|
298
|
-
data[offset + 4] = v[3];
|
|
299
|
-
data[offset + 5] = v[4];
|
|
300
|
-
data[offset + 6] = v[5];
|
|
301
|
-
data[offset + 8] = v[6];
|
|
302
|
-
data[offset + 9] = v[7];
|
|
303
|
-
data[offset + 10] = v[8];`,"mat4x4<f32>":`
|
|
304
|
-
for (let i = 0; i < 16; i++) {
|
|
305
|
-
data[offset + i] = v[i];
|
|
306
|
-
}`,"mat3x2<f32>":$(3,2),"mat4x2<f32>":$(4,2),"mat2x3<f32>":$(2,3),"mat4x3<f32>":$(4,3),"mat2x4<f32>":$(2,4),"mat3x4<f32>":$(3,4)},vt={..._t,"mat2x2<f32>":`
|
|
307
|
-
data[offset] = v[0];
|
|
308
|
-
data[offset + 1] = v[1];
|
|
309
|
-
data[offset + 2] = v[2];
|
|
310
|
-
data[offset + 3] = v[3];
|
|
311
|
-
`};function yt(e,t,n,r,i,a){let o=a?1:-1;return e.identity(),e.a=1/r*2,e.d=o*(1/i*2),e.tx=-1-t*e.a,e.ty=-o-n*e.d,e}function bt(e){let t=e.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}var xt=class{constructor(e){this.rootViewPort=new g,this.viewport=new g,this.onRenderTargetChange=new xe(`onRenderTargetChange`),this.projectionMatrix=new h,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=e}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:e,clear:t,clearColor:n,frame:r}){this._renderTargetStack.length=0,this.push(e,t,n,r),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=bt(this.rootRenderTarget)}bind(e,t=!0,n,r){let i=this.getRenderTarget(e),a=this.renderTarget!==i;this.renderTarget=i,this.renderSurface=e;let o=this.getGpuRenderTarget(i);(i.pixelWidth!==o.width||i.pixelHeight!==o.height)&&(this.adaptor.resizeGpuRenderTarget(i),o.width=i.pixelWidth,o.height=i.pixelHeight);let c=i.colorTexture,l=this.viewport,u=c.pixelWidth,d=c.pixelHeight;if(!r&&e instanceof s&&(r=e.frame),r){let e=c._resolution;l.x=r.x*e+.5|0,l.y=r.y*e+.5|0,l.width=r.width*e+.5|0,l.height=r.height*e+.5|0}else l.x=0,l.y=0,l.width=u,l.height=d;return yt(this.projectionMatrix,0,0,l.width/c.resolution,l.height/c.resolution,!i.isRoot),this.adaptor.startRenderPass(i,t,n,l),a&&this.onRenderTargetChange.emit(i),i}clear(e,t=T.ALL,n){t&&(e&&=this.getRenderTarget(e),this.adaptor.clear(e||this.renderTarget,t,n,this.viewport))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(e,t=T.ALL,n,r){let i=this.bind(e,t,n,r);return this._renderTargetStack.push({renderTarget:i,frame:r}),i}pop(){this._renderTargetStack.pop();let e=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(e.renderTarget,!1,null,e.frame)}getRenderTarget(e){return e.isTexture&&(e=e.source),this._renderSurfaceToRenderTargetHash.get(e)??this._initRenderTarget(e)}copyToTexture(e,t,n,r,i){n.x<0&&(r.width+=n.x,i.x-=n.x,n.x=0),n.y<0&&(r.height+=n.y,i.y-=n.y,n.y=0);let{pixelWidth:a,pixelHeight:o}=e;return r.width=Math.min(r.width,a-n.x),r.height=Math.min(r.height,o-n.y),this.adaptor.copyToTexture(e,t,n,r,i)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((e,t)=>{e!==t&&e.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(e){let n=null;return l.test(e)&&(e=ut(e).source),e instanceof J?n=e:e instanceof t&&(n=new J({colorTextures:[e]}),l.test(e.source.resource)&&(n.isRoot=!0),e.once(`destroy`,()=>{n.destroy(),this._renderSurfaceToRenderTargetHash.delete(e);let t=this._gpuRenderTargetHash[n.uid];t&&(this._gpuRenderTargetHash[n.uid]=null,this.adaptor.destroyGpuRenderTarget(t))})),this._renderSurfaceToRenderTargetHash.set(e,n),n}getGpuRenderTarget(e){return this._gpuRenderTargetHash[e.uid]||(this._gpuRenderTargetHash[e.uid]=this.adaptor.initGpuRenderTarget(e))}},St=class extends oe{constructor({buffer:e,offset:t,size:n}){super(),this.uid=y(`buffer`),this._resourceType=`bufferResource`,this._touched=0,this._resourceId=y(`resource`),this._bufferResource=!0,this.destroyed=!1,this.buffer=e,this.offset=t|0,this.size=n,this.buffer.on(`change`,this.onBufferChange,this)}onBufferChange(){this._resourceId=y(`resource`),this.emit(`change`,this)}destroy(e=!1){this.destroyed=!0,e&&this.buffer.destroy(),this.emit(`change`,this),this.buffer=null}};export{gt as a,Z as c,dt as d,B as f,ve as g,_e as h,vt as i,pt as l,T as m,xt as n,Q as o,we as p,_t as r,ht as s,St as t,ft as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{H as e,L as t,M as n,U as r,j as i}from"./localUniformBit-BnogyqF-.js";var a={};function o(e,t){let n=2166136261;for(let r=0;r<t;r++)n^=e[r].uid,n=Math.imul(n,16777619),n>>>=0;return a[n]||c(e,t,n)}var s=0;function c(e,r,o){let c={},l=0;s||=i();for(let n=0;n<s;n++){let i=n<r?e[n]:t.EMPTY.source;c[l++]=i.source,c[l++]=i.style}let u=new n(c);return a[o]=u,u}var l=new class{constructor(e){this._canvasPool=Object.create(null),this.canvasOptions=e||{},this.enableFullScreen=!1}_createCanvasAndContext(e,t){let n=r.get().createCanvas();return n.width=e,n.height=t,{canvas:n,context:n.getContext(`2d`)}}getOptimalCanvasAndContext(t,n,r=1){t=Math.ceil(t*r-1e-6),n=Math.ceil(n*r-1e-6),t=e(t),n=e(n);let i=(t<<17)+(n<<1);this._canvasPool[i]||(this._canvasPool[i]=[]);let a=this._canvasPool[i].pop();return a||=this._createCanvasAndContext(t,n),a}returnCanvasAndContext(e){let{width:t,height:n}=e.canvas,r=(t<<17)+(n<<1);this._canvasPool[r].push(e)}clear(){this._canvasPool={}}};export{o as n,l as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./chunk-QTnfLwEv.js";import{n as t,t as n}from"./jsx-runtime-BWRPWl8p.js";import{i as r,n as i}from"./WorldSurface-4GHZpnMP.js";import{A as a,C as o,D as s,M as c,N as l,P as u,S as d,h as f,j as p}from"./index-B8V-qiZs.js";var m=u(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),h=u(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),ee=u(`zoom-in`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),te=u(`zoom-out`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),g=e(t(),1);function _(e,t,n,r={}){let i=t.nodes.filter(e=>e.kind===`space`||!e.parentId||!n.has(e.parentId)),a=new Set(i.map(({id:e})=>e)),o=t.edges.filter(({sourceId:e,targetId:t})=>a.has(e)&&a.has(t)),s=JSON.stringify({nodes:i.map(({id:e})=>e).sort(),edges:o.map(({sourceId:e,targetId:t})=>[e,t]).sort(T)}),c=new Map,l=i.filter(({kind:e})=>e===`space`);for(let[t,n]of l.entries())c.set(n.id,x(e,n,t,l.length,r[n.id]));for(let t of i){if(t.kind!==`terminal`)continue;let n=t.parentId?c.get(t.parentId):null;c.set(t.id,S(e,t,n,r[t.id]))}return{state:{nodes:c,edges:o,topologyKey:s},topologyChanged:e?.topologyKey!==s}}function v(e,t){let n=[...e.nodes.values()].filter(({kind:e})=>e===`space`),r=new Map;for(let t of e.nodes.values())if(t.kind===`terminal`&&t.parentId){let e=r.get(t.parentId)??[];e.push(t),r.set(t.parentId,e)}for(let e=0;e<n.length;e+=1){let r=n[e];if(r){r.pinned||(r.vx+=-r.x*7e-4*t,r.vy+=-r.y*7e-4*t);for(let i=e+1;i<n.length;i+=1){let e=n[i];e&&E(r,e,230,2.2,t)}}}for(let[n,i]of r){let r=e.nodes.get(n);if(r)for(let e=0;e<i.length;e+=1){let n=i[e];if(n){n.pinned||D(n,r,110,.028,t);for(let r=e+1;r<i.length;r+=1){let e=i[r];e&&E(n,e,58,1.5,t)}}}}let i=0;for(let t of e.nodes.values()){if(t.pinned){t.vx=0,t.vy=0;continue}t.vx*=.82,t.vy*=.82;let e=Math.hypot(t.vx,t.vy);e>14&&(t.vx=t.vx/e*14,t.vy=t.vy/e*14),t.x+=t.vx,t.y+=t.vy,i+=Math.abs(t.vx)+Math.abs(t.vy)}return i}function y(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e){let e=a.kind===`space`?54:24;t=Math.min(t,a.x-e),n=Math.min(n,a.y-e),r=Math.max(r,a.x+e),i=Math.max(i,a.y+e)}return Number.isFinite(t)?{minX:t,minY:n,maxX:r,maxY:i}:{minX:-1,minY:-1,maxX:1,maxY:1}}function b(e){let t={};if(!e)return t;for(let n of e.nodes.values())t[n.id]={x:n.x,y:n.y,pinned:n.pinned};return t}function x(e,t,n,r,i){let a=e?.nodes.get(t.id);if(a)return a.source=t,a.parentId=t.parentId,a;let o=n*2.399963229728653+w(t.id),s=Math.max(100,Math.sqrt(Math.max(1,r))*74)*Math.sqrt((n+1)/r);return C(t,i?.x??Math.cos(o)*s,i?.y??Math.sin(o)*s,i?.pinned??!1)}function S(e,t,n,r){let i=e?.nodes.get(t.id);if(i)return i.source=t,i.parentId=t.parentId,i;let a=w(t.id)*Math.PI*2;return C(t,r?.x??(n?.x??0)+Math.cos(a)*86,r?.y??(n?.y??0)+Math.sin(a)*86,r?.pinned??!1)}function C(e,t,n,r){return{id:e.id,source:e,kind:e.kind,parentId:e.parentId,x:t,y:n,vx:0,vy:0,pinned:r}}function w(e){return f(e)/4294967295}function T(e,t){return e[0]?.localeCompare(t[0]??``)||e[1]?.localeCompare(t[1]??``)||0}function E(e,t,n,r,i){let a=t.x-e.x,o=t.y-e.y,s=Math.hypot(a,o);if(s<.01&&(a=w(e.id)-.5,o=w(t.id)-.5,s=Math.max(.01,Math.hypot(a,o))),s>=n)return;let c=(n-s)/n*r*i,l=a/s*c,u=o/s*c;e.pinned||(e.vx-=l,e.vy-=u),t.pinned||(t.vx+=l,t.vy+=u)}function D(e,t,n,r,i){let a=t.x-e.x,o=t.y-e.y,s=Math.max(.01,Math.hypot(a,o)),c=(s-n)*r*i;e.vx+=a/s*c,e.vy+=o/s*c,t.pinned||(t.vx-=a/s*c*.18,t.vy-=o/s*c*.18)}var O=n(),k=.25,A=3,j=1.25,M=32,ne=(0,g.forwardRef)(function({projection:e,collapsedIds:t,selectedKey:n,matchedIds:r,conversationTargets:i,initialPrefs:a,fitOnMount:o=!1,onSelect:s,onActivate:c,onToggleCollapse:l,onViewChange:u},d){let f=(0,g.useRef)(null),p=(0,g.useRef)(null),m=(0,g.useRef)(null),h=(0,g.useRef)(null);return(0,g.useLayoutEffect)(()=>{let e=f.current,t=p.current,n=m.current;if(!e||!t||!n)return;let r=new P(t,n,e,a,o);return h.current=r,()=>{r.dispose(),h.current=null}},[o,a]),(0,g.useEffect)(()=>{h.current?.setCallbacks(s,c,l,u)},[c,s,l,u]),(0,g.useEffect)(()=>{h.current?.update(e,t,n,r)},[t,r,e,n]),(0,g.useEffect)(()=>{h.current?.setConversationTargets(i)},[i]),(0,g.useImperativeHandle)(d,()=>({fit:()=>h.current?.fit(),zoomIn:()=>h.current?.zoomIn(),zoomOut:()=>h.current?.zoomOut()}),[]),(0,O.jsxs)(`div`,{ref:f,className:`graph-canvas-host`,children:[(0,O.jsx)(`canvas`,{ref:p,"data-graph-canvas":`true`,"aria-hidden":`true`}),(0,O.jsx)(`svg`,{ref:m,className:`graph-conversation-connectors`,"data-graph-conversation-connectors":`true`,"aria-hidden":`true`})]})}),N=class{#e=null;#t=null;#n;constructor(e){this.#n=e}push(e){this.#t=e,this.#e===null&&(this.#e=window.requestAnimationFrame(()=>{this.#e=null;let e=this.#t;this.#t=null,e!==null&&this.#n(e)}))}cancel(){this.#e!==null&&window.cancelAnimationFrame(this.#e),this.#e=null,this.#t=null}},P=class{#e;#t;#n;#r;#i;#a;#o=null;#s;#c=new Set;#l=new Set;#u=null;#d=null;#f;#p;#m;#h=1;#g=1;#_=0;#v=null;#y=null;#b=!1;#x=document.visibilityState===`hidden`;#S=()=>{};#C=()=>{};#w=[];#T=new Map;#E=new Map;#D=new Map;#O=()=>{};#k=()=>{};constructor(e,t,n,r,i){this.#e=e,this.#t=t,this.#n=e.getContext(`2d`),this.#f={...r.camera},this.#p=r.cameraMode,this.#m=i,this.#s={...r.positions},this.#r=ie(),this.#r.mounts+=1,this.#r.activeRenderers+=1,this.#r.canvases+=1,this.#r.ready=!0,this.#r.paused=this.#x,this.#i=new N(({width:e,height:t})=>{this.#b||(this.#r.resizeFrames+=1,this.#A(e,t))}),this.#a=typeof ResizeObserver>`u`?null:new ResizeObserver(e=>{let t=e.at(-1);t&&(this.#r.resizeObservations+=e.length,this.#i.push({width:t.contentRect.width,height:t.contentRect.height}))}),this.#a?.observe(n),this.#a&&(this.#r.activeObservers+=1),e.addEventListener(`pointerdown`,this.#R),e.addEventListener(`pointermove`,this.#z),e.addEventListener(`pointerup`,this.#B),e.addEventListener(`pointercancel`,this.#V),e.addEventListener(`wheel`,this.#H,{passive:!1}),e.addEventListener(`dblclick`,this.#W),document.addEventListener(`visibilitychange`,this.#J),this.#r.activeListeners+=7;let a=n.getBoundingClientRect();this.#A(Math.max(1,a.width),Math.max(1,a.height))}setCallbacks(e,t,n,r){this.#S=e,this.#C=t,this.#O=n,this.#k=r}setConversationTargets(e){this.#w=e;let t=new Set(e.map(({id:e})=>e));for(let[e,n]of this.#E)t.has(e)||(n.path.remove(),n.dot.remove(),this.#E.delete(e),this.#D.delete(e));for(let t of e){if(this.#E.has(t.id))continue;let e=document.createElementNS(`http://www.w3.org/2000/svg`,`path`),n=document.createElementNS(`http://www.w3.org/2000/svg`,`circle`);e.dataset.windowId=t.id,n.dataset.windowId=t.id,n.setAttribute(`r`,`4`),this.#t.append(e,n),this.#E.set(t.id,{path:e,dot:n})}this.#K(),this.#r.conversationLinks=e.length,this.#j()}update(e,t,n,r){this.#c=new Set(e.nodes.map(({id:e})=>e)),this.#T=new Map(e.nodes.flatMap(e=>e.kind===`terminal`&&e.parentId?[[e.selectionKey,e.parentId]]:[])),this.#s=L(this.#s,null,this.#c);let i=_(this.#o,e,t,this.#s);this.#o=i.state,this.#l=t,this.#u=n,this.#d=r,this.#r.nodes=this.#o.nodes.size,this.#r.links=this.#o.edges.length,i.topologyChanged&&(this.#_=1),this.#K(),this.#j()}fit(){if(!this.#o)return;this.#m=!1,this.#p=`fit`;let e=y(this.#o.nodes.values()),t=Math.max(1,e.maxX-e.minX),n=Math.max(1,e.maxY-e.minY),r=V(Math.min((this.#h-96)/t,(this.#g-96)/n),k,2);this.#f={x:-(e.minX+e.maxX)/2*r,y:-(e.minY+e.maxY)/2*r,zoom:r},this.#Y(),this.#D.clear(),this.#K(),this.#j()}zoomIn(){this.#U(this.#f.zoom*j,0,0)}zoomOut(){this.#U(this.#f.zoom/j,0,0)}dispose(){if(!this.#b){this.#b=!0,this.#M(),this.#i.cancel(),this.#a?.disconnect(),this.#e.removeEventListener(`pointerdown`,this.#R),this.#e.removeEventListener(`pointermove`,this.#z),this.#e.removeEventListener(`pointerup`,this.#B),this.#e.removeEventListener(`pointercancel`,this.#V),this.#e.removeEventListener(`wheel`,this.#H),this.#e.removeEventListener(`dblclick`,this.#W),document.removeEventListener(`visibilitychange`,this.#J),this.#y=null,this.#o?.nodes.clear(),this.#o=null,this.#e.width=0,this.#e.height=0,this.#r.destroys+=1,--this.#r.activeRenderers,--this.#r.canvases,this.#r.activeListeners-=7,this.#a&&--this.#r.activeObservers,this.#r.ready=this.#r.activeRenderers>0,this.#r.paused=this.#r.activeRenderers>0&&this.#x,this.#r.nodes=0,this.#r.links=0,this.#r.conversationLinks=0;for(let e of this.#E.values())e.path.remove(),e.dot.remove();this.#E.clear(),this.#D.clear()}}#A(e,t){let n=Math.max(1,Math.round(e)),r=Math.max(1,Math.round(t));if(n===this.#h&&r===this.#g)return;this.#h=n,this.#g=r;let i=Math.min(2,Math.max(1,window.devicePixelRatio||1));this.#e.width=Math.round(n*i),this.#e.height=Math.round(r*i),this.#e.style.width=`${n}px`,this.#e.style.height=`${r}px`,this.#t.setAttribute(`viewBox`,`0 0 ${n} ${r}`),this.#t.setAttribute(`width`,String(n)),this.#t.setAttribute(`height`,String(r)),this.#j()}#j(){this.#b||this.#x||this.#v!==null||(this.#v=window.requestAnimationFrame(this.#N),this.#r.activeAnimationFrames+=1)}#M(){this.#v!==null&&(window.cancelAnimationFrame(this.#v),this.#v=null,--this.#r.activeAnimationFrames)}#N=()=>{if(this.#v=null,--this.#r.activeAnimationFrames,!(this.#b||this.#x)){if(this.#o&&this.#_>.015){let e=v(this.#o,this.#_);this.#_*=e<.08?.78:.93}else this.#_=0;this.#_<=.015&&(this.#_=0,this.#m&&this.#o&&this.#o.nodes.size>0&&this.fit()),this.#P(),this.#r.frames+=1,this.#_>.015&&this.#j()}};#P(){let e=this.#n,t=this.#o;if(!e||!t)return;let n=Math.min(2,Math.max(1,window.devicePixelRatio||1));e.setTransform(n,0,0,n,0,0),e.clearRect(0,0,this.#h,this.#g),e.fillStyle=`#080812`,e.fillRect(0,0,this.#h,this.#g),ae(e,this.#h,this.#g,this.#f),e.save(),e.translate(this.#h/2+this.#f.x,this.#g/2+this.#f.y),e.scale(this.#f.zoom,this.#f.zoom);for(let n of t.edges){let r=t.nodes.get(n.sourceId),i=t.nodes.get(n.targetId);!r||!i||(e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(i.x,i.y),e.strokeStyle=`rgba(137, 180, 250, 0.34)`,e.lineWidth=1.5/this.#f.zoom,e.stroke())}let r=[...t.nodes.values()].sort((e,t)=>Number(e.kind===`space`)-Number(t.kind===`space`));for(let t of r)this.#F(e,t);e.restore(),this.#G(t)}#F(e,t){let n=t.source,r=n.kind===`space`?47:22,i=!this.#d||this.#d.has(n.id);e.save(),e.globalAlpha=i?1:.2,e.translate(t.x,t.y),e.beginPath(),e.arc(0,0,r,0,Math.PI*2),e.fillStyle=n.kind===`space`?`#181825`:oe(n.status),e.fill(),e.setLineDash(n.stale?[5,4]:[]),e.lineWidth=n.selectionKey===this.#u?4:n.focused?3:1.5,e.strokeStyle=n.selectionKey===this.#u?`#f9e2af`:n.focused?`#89b4fa`:I(n.status),e.stroke(),e.setLineDash([]),e.fillStyle=`#f5e0dc`,e.textAlign=`center`,e.textBaseline=`middle`,e.font=n.kind===`space`?`600 11px sans-serif`:`700 12px sans-serif`,n.kind===`terminal`?(le(e,n),e.font=`600 9px sans-serif`,e.fillStyle=`#cdd6f4`,e.fillText(B(e,n.label,70),0,r+14)):(e.fillText(B(e,n.label,76),0,-5),e.font=`500 8px sans-serif`,e.fillStyle=`#a6adc8`,e.fillText(B(e,n.hostLabel,72),0,11),n.omittedChildCount>0&&(e.fillStyle=`#f9e2af`,e.fillText(`+${n.omittedChildCount} terminals`,0,25)),e.beginPath(),e.arc(36,-36,11,0,Math.PI*2),e.fillStyle=`#313244`,e.fill(),e.strokeStyle=`#89b4fa`,e.lineWidth=1.5,e.stroke(),e.fillStyle=`#cdd6f4`,e.font=`700 14px sans-serif`,e.fillText(this.#l.has(n.id)?`+`:`−`,36,-36)),n.stale&&(e.fillStyle=`#f38ba8`,e.font=`700 10px sans-serif`,e.fillText(n.disconnected?`OFFLINE`:n.connectionState.toLocaleUpperCase(),0,-r-10)),e.restore()}#I(e){let t=this.#e.getBoundingClientRect();return{clientX:e.clientX-t.left,clientY:e.clientY-t.top,worldX:(e.clientX-t.left-this.#h/2-this.#f.x)/this.#f.zoom,worldY:(e.clientY-t.top-this.#g/2-this.#f.y)/this.#f.zoom}}#L(e,t){if(!this.#o)return null;let n=[...this.#o.nodes.values()].reverse();for(let r of n){if(r.kind===`space`&&Math.hypot(e-(r.x+36),t-(r.y-36))<=14)return r;let n=r.kind===`space`?50:25;if(Math.hypot(e-r.x,t-r.y)<=n)return r}return null}#R=e=>{if(e.button!==0)return;let t=this.#I(e),n=this.#L(t.worldX,t.worldY),r=n?.kind===`space`&&Math.hypot(t.worldX-(n.x+36),t.worldY-(n.y-36))<=14;this.#y={pointerId:e.pointerId,mode:r?`collapse`:n?`node`:`pan`,nodeId:n?.id??null,lastX:e.clientX,lastY:e.clientY,startX:e.clientX,startY:e.clientY,moved:!1},this.#e.setPointerCapture?.(e.pointerId),e.preventDefault()};#z=e=>{let t=this.#y;if(!t||t.pointerId!==e.pointerId)return;let n=e.clientX-t.lastX,r=e.clientY-t.lastY;if(t.lastX=e.clientX,t.lastY=e.clientY,t.moved||=Math.hypot(e.clientX-t.startX,e.clientY-t.startY)>4,!(!t.moved||t.mode===`collapse`)){if(t.mode===`pan`)this.#f={...this.#f,x:this.#f.x+n,y:this.#f.y+r},this.#p=`manual`,this.#m=!1;else if(t.nodeId&&this.#o){let e=this.#o.nodes.get(t.nodeId);e&&(e.x+=n/this.#f.zoom,e.y+=r/this.#f.zoom,e.pinned=!0,this.#_=Math.max(this.#_,.24))}this.#j()}};#B=e=>{let t=this.#y;if(!(!t||t.pointerId!==e.pointerId))if(this.#y=null,this.#e.releasePointerCapture?.(e.pointerId),!t.moved&&t.nodeId&&this.#o){let e=this.#o.nodes.get(t.nodeId);t.mode===`collapse`&&e?.kind===`space`?this.#O(e.id):e&&this.#S(e.source.selectionKey,e.source.hostKey)}else t.moved&&this.#Y()};#V=e=>{this.#y?.pointerId===e.pointerId&&(this.#y=null,this.#Y())};#H=e=>{e.preventDefault();let t=this.#e.getBoundingClientRect(),n=e.clientX-t.left-this.#h/2,r=e.clientY-t.top-this.#g/2;this.#U(this.#f.zoom*Math.exp(-e.deltaY*.0015),n,r)};#U(e,t,n){let r=V(e,k,A);if(r===this.#f.zoom)return;let i=(t-this.#f.x)/this.#f.zoom,a=(n-this.#f.y)/this.#f.zoom;this.#f={x:t-i*r,y:n-a*r,zoom:r},this.#p=`manual`,this.#m=!1,this.#Y(),this.#j()}#W=e=>{let t=this.#I(e),n=this.#L(t.worldX,t.worldY);n?.source.kind!==`terminal`||!n.source.actionable||(e.preventDefault(),this.#C(n.source))};#G(e){let t=new Map([...e.nodes.values()].map(e=>[e.source.selectionKey,e]));for(let n of this.#w){let r=this.#E.get(n.id),i=t.get(n.selectionKey),a=`terminal`;if(!i){let t=this.#T.get(n.selectionKey);i=t?e.nodes.get(t):void 0,a=`collapsed-parent`}if(!r||!i){r?.path.setAttribute(`visibility`,`hidden`),r?.dot.setAttribute(`visibility`,`hidden`),r&&(delete r.path.dataset.anchorKind,delete r.dot.dataset.anchorKind);continue}r.path.dataset.anchorKind=a,r.dot.dataset.anchorKind=a;let o=this.#h/2+this.#f.x+i.x*this.#f.zoom,s=this.#g/2+this.#f.y+i.y*this.#f.zoom,c=[{x:n.rect.left,y:V(s,n.rect.top+18,n.rect.bottom-18)},{x:n.rect.right,y:V(s,n.rect.top+18,n.rect.bottom-18)},{x:V(o,n.rect.left+18,n.rect.right-18),y:n.rect.top},{x:V(o,n.rect.left+18,n.rect.right-18),y:n.rect.bottom}].reduce((e,t)=>Math.hypot(t.x-o,t.y-s)<Math.hypot(e.x-o,e.y-s)?t:e),l=c.x-o,u=c.y-s;r.path.setAttribute(`d`,`M ${o} ${s} C ${o+l*.42} ${s+u*.12}, ${c.x-l*.12} ${c.y-u*.42}, ${c.x} ${c.y}`),r.path.removeAttribute(`visibility`),r.dot.setAttribute(`cx`,String(o)),r.dot.setAttribute(`cy`,String(s)),r.dot.removeAttribute(`visibility`)}}#K(){let e=this.#o;if(!e)return;let t=new Map([...e.nodes.values()].map(e=>[e.source.selectionKey,e]));for(let n of this.#w){let r=this.#T.get(n.selectionKey),i=t.get(n.selectionKey)??(r?e.nodes.get(r):void 0);if(!i){this.#D.delete(n.id);continue}let a=re(n,i.id);this.#D.get(n.id)!==a&&(this.#q(n,i),this.#D.set(n.id,a))}}#q(e,t){let n=F({x:this.#h/2+this.#f.x+t.x*this.#f.zoom,y:this.#g/2+this.#f.y+t.y*this.#f.zoom},e.rect);(n.x!==0||n.y!==0)&&(this.#f={...this.#f,x:this.#f.x+n.x,y:this.#f.y+n.y})}#J=()=>{this.#x=document.visibilityState===`hidden`,this.#r.paused=this.#x,this.#x?this.#M():this.#j()};#Y(){this.#o&&(this.#s=L(this.#s,this.#o,this.#c),this.#k({...this.#f},this.#s,this.#p))}};function F(e,t){let n=Math.max(t.left-e.x,0,e.x-t.right),r=Math.max(t.top-e.y,0,e.y-t.bottom);return Math.hypot(n,r)>=M?{x:0,y:0}:[{x:t.left-M-e.x,y:0},{x:t.right+M-e.x,y:0},{x:0,y:t.top-M-e.y},{x:0,y:t.bottom+M-e.y}].reduce((e,t)=>Math.hypot(t.x,t.y)<Math.hypot(e.x,e.y)?t:e)}function re(e,t){let{left:n,top:r,right:i,bottom:a}=e.rect;return`${t}:${n}:${r}:${i}:${a}`}function ie(){return window.__HERDR_GRAPH_RENDERER__||(window.__HERDR_GRAPH_RENDERER__={mounts:0,destroys:0,activeRenderers:0,activeAnimationFrames:0,activeObservers:0,activeConversationObservers:0,activeListeners:0,canvases:0,frames:0,resizeObservations:0,resizeFrames:0,ready:!1,paused:!1,nodes:0,links:0,conversationLinks:0}),window.__HERDR_GRAPH_RENDERER__}function ae(e,t,n,r){let i=48*r.zoom;if(i<12)return;let a=((t/2+r.x)%i+i)%i,o=((n/2+r.y)%i+i)%i;e.beginPath();for(let r=a;r<t;r+=i)e.moveTo(r,0),e.lineTo(r,n);for(let r=o;r<n;r+=i)e.moveTo(0,r),e.lineTo(t,r);e.strokeStyle=`rgba(88, 91, 112, 0.16)`,e.lineWidth=1,e.stroke()}function oe(e){return e===`working`?`#24433d`:e===`blocked`?`#4a2838`:e===`done`?`#243c45`:e===`idle`?`#373347`:`#28283a`}function I(e){return e===`working`?`#a6e3a1`:e===`blocked`?`#f38ba8`:e===`done`?`#89dceb`:e===`idle`?`#cba6f7`:`#7f849c`}function se(e){return e.agentKind??(e.agentRunning?`generic-agent`:`terminal`)}function L(e,t,n){let r=b(t),i={};for(let t of n){let n=r[t]??e[t];n&&(i[t]=n)}return i}var ce={"generic-agent":`M12 8V4H8 M6 8h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2 M2 14h2 M20 14h2 M15 13v2 M9 13v2`,terminal:`m7 11 2-2-2-2 M11 13h4 M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2`},R=new Map;function le(e,t){let n=se(t);if(e.save(),e.translate(0,-2),n===`generic-agent`||n===`terminal`){let t=.76;e.scale(t,t),e.translate(-12,-12),e.strokeStyle=`#f5e0dc`,e.lineWidth=2,e.lineCap=`round`,e.lineJoin=`round`,e.stroke(z(ce[n]))}else{let t=d[n],[r,i,a,o]=t.viewBox.split(` `).map(Number),s=Math.min(18/a,18/o);e.scale(s,s),e.translate(-(r+a/2),-(i+o/2)),e.fillStyle=n===`claude`?`#d97757`:`#f5e0dc`;let c=e.globalAlpha;for(let n of t.paths)e.globalAlpha=c*(n.opacity??1),e.fill(z(n.d),n.fillRule??`nonzero`)}e.restore(),e.beginPath(),e.arc(15,-15,6.5,0,Math.PI*2),e.fillStyle=`#080812`,e.fill(),e.lineWidth=1.25,e.strokeStyle=I(t.status),e.stroke(),e.fillStyle=`#f5e0dc`,e.font=`700 7px sans-serif`,e.fillText(ue(t.status),15,-14.5)}function z(e){let t=R.get(e);if(t)return t;let n=new Path2D(e);return R.set(e,n),n}function ue(e){return e===`working`?`▶`:e===`blocked`?`!`:e===`done`?`✓`:e===`idle`?`○`:`?`}function B(e,t,n){if(e.measureText(t).width<=n)return t;let r=[...t];for(;r.length>1&&e.measureText(`${r.join(``)}…`).width>n;)r.pop();return`${r.join(``)}…`}function V(e,t,n){return Math.min(n,Math.max(t,e))}var H=`herdr.world.graph-view.v1`,U=2304,de=512,fe=1e6;Object.freeze({camera:Object.freeze({x:0,y:0,zoom:1}),cameraMode:`fit`,collapsedIds:Object.freeze([]),positions:Object.freeze({})});function pe(){try{let e=window.localStorage.getItem(H);if(!e)return{prefs:G(),fitOnMount:!0};let t=W(JSON.parse(e));return{prefs:t,fitOnMount:t.cameraMode===`fit`}}catch{return{prefs:G(),fitOnMount:!0}}}function me(e){try{window.localStorage.setItem(H,JSON.stringify(W(e)))}catch{}}function W(e){if(!Y(e))return G();let t=Y(e.camera)?e.camera:{},n=q(t.x)&&q(t.y)&&J(t.zoom),r={x:q(t.x)?t.x:0,y:q(t.y)?t.y:0,zoom:J(t.zoom)?t.zoom:1},i=n&&e.cameraMode===`manual`?`manual`:`fit`,a=Array.isArray(e.collapsedIds)?[...new Set(e.collapsedIds.filter(K))].slice(0,U):[],o={};if(Y(e.positions))for(let[t,n]of Object.entries(e.positions).slice(0,U))!K(t)||!Y(n)||q(n.x)&&q(n.y)&&typeof n.pinned==`boolean`&&(o[t]={x:n.x,y:n.y,pinned:n.pinned});return{camera:r,cameraMode:i,collapsedIds:a,positions:o}}function G(){return{camera:{x:0,y:0,zoom:1},cameraMode:`fit`,collapsedIds:[],positions:{}}}function K(e){return typeof e==`string`&&e.length>0&&e.length<=de}function q(e){return typeof e==`number`&&Number.isFinite(e)&&Math.abs(e)<=fe}function J(e){return typeof e==`number`&&Number.isFinite(e)&&e>=.25&&e<=3}function Y(e){return typeof e==`object`&&!!e}function he(e){if(!i(e))return!1;let t=e;return!!t.graphProjection&&typeof t.onGraphSelect==`function`&&typeof t.onGraphOpenTerminal==`function`&&typeof t.onGraphOpenInSpaces==`function`}function ge({context:e}){return he(e)?(0,O.jsx)(_e,{context:e}):(0,O.jsxs)(`div`,{className:`surface-unavailable`,role:`alert`,children:[(0,O.jsx)(`strong`,{children:`Graph unavailable`}),(0,O.jsx)(`span`,{children:`The shared World context is not ready.`})]})}function _e({context:e}){let t=e.graphProjection,[n]=(0,g.useState)(pe),{prefs:i,fitOnMount:o}=n,[s,c]=(0,g.useState)(()=>new Set(i.collapsedIds)),[u,d]=(0,g.useState)(``),[f,m]=(0,g.useState)([]),{rects:_}=r(),v=(0,g.useRef)(e.conversationBubbles);v.current=e.conversationBubbles;let y=e.conversationBubbles.map(e=>`${e.id}:${e.selectedKey??e.targetKey}`).join(`|`),b=(0,g.useRef)(``),x=(0,g.useRef)(null),S=(0,g.useRef)(null),C=(0,g.useRef)(new Map),w=(0,g.useRef)(null),T=(0,g.useRef)(i),E=(0,g.useRef)(null),D=(0,g.useRef)(s),k=(0,g.useCallback)(e=>{T.current=e,E.current!==null&&window.clearTimeout(E.current),E.current=window.setTimeout(()=>{E.current=null,me(T.current)},120)},[]);(0,g.useEffect)(()=>()=>{E.current!==null&&window.clearTimeout(E.current),me(T.current)},[]);let A=(0,g.useMemo)(()=>be(t.spaces,u),[t.spaces,u]),j=(0,g.useMemo)(()=>u.trim()?t.spaces.filter(({node:e,terminals:t})=>A?.has(e.id)||t.some(({id:e})=>A?.has(e))):t.spaces,[A,t.spaces,u]),M=t.nodes.find(({selectionKey:t})=>t===e.selectedKey)??null;(0,g.useEffect)(()=>{let t=w.current;!t||e.selectedKey!==t||(w.current=null,C.current.get(t)?.focus())},[e.selectedKey]);let N=(0,g.useCallback)((t,n)=>{w.current=t,e.onGraphSelect(t,n)},[e]),P=(0,g.useCallback)(e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),D.current=n,k({...T.current,collapsedIds:[...n]}),n})},[k]),F=(0,g.useCallback)((e,t,n)=>{k({camera:e,cameraMode:n,positions:t,collapsedIds:[...D.current]})},[k]),re=(e,t)=>{t?C.current.set(e,t):C.current.delete(e)};return(0,g.useLayoutEffect)(()=>{let e=S.current;if(!e)return;let t=e.getBoundingClientRect(),n=v.current.flatMap(e=>{let n=_[e.id],r=e.selectedKey??e.targetKey;return!n||!r?[]:[{id:e.id,selectionKey:r,rect:{left:n.left-t.left,top:n.top-t.top,right:n.right-t.left,bottom:n.bottom-t.top}}]}),r=JSON.stringify(n);r!==b.current&&(b.current=r,m(n))},[y,_]),(0,O.jsxs)(`div`,{className:`graph-stage-shell`,children:[(0,O.jsxs)(`header`,{className:`graph-stage-bar`,children:[(0,O.jsx)(`button`,{className:`icon-btn`,type:`button`,"aria-label":e.compact?`Back to Herdr sidebar`:`Toggle sidebar`,title:e.compact?`Back`:`Toggle sidebar`,onClick:e.compact?e.onBackToSidebar:e.onToggleSidebar,children:e.compact?(0,O.jsx)(l,{size:20}):(0,O.jsx)(a,{size:18})}),(0,O.jsxs)(`div`,{className:`graph-stage-heading`,children:[(0,O.jsx)(`strong`,{children:`World Graph`}),(0,O.jsxs)(`span`,{children:[t.coverage.presentedSpaces,` spaces · `,t.coverage.presentedTerminals,` terminals`]})]}),(0,O.jsxs)(`label`,{className:`graph-search`,children:[(0,O.jsx)(h,{size:14,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`sr-only`,children:`Search Graph`}),(0,O.jsx)(`input`,{type:`search`,value:u,placeholder:`Search spaces and terminals`,onChange:e=>d(e.currentTarget.value)})]}),(0,O.jsxs)(`div`,{className:`graph-zoom-controls`,role:`group`,"aria-label":`Graph zoom controls`,children:[(0,O.jsx)(`button`,{className:`icon-btn graph-zoom-button`,type:`button`,"aria-label":`Zoom out`,title:`Zoom out`,onClick:()=>x.current?.zoomOut(),children:(0,O.jsx)(te,{size:16,"aria-hidden":`true`})}),(0,O.jsx)(`button`,{className:`icon-btn graph-zoom-button`,type:`button`,"aria-label":`Zoom in`,title:`Zoom in`,onClick:()=>x.current?.zoomIn(),children:(0,O.jsx)(ee,{size:16,"aria-hidden":`true`})})]}),(0,O.jsxs)(`button`,{className:`btn graph-fit`,type:`button`,onClick:()=>x.current?.fit(),children:[(0,O.jsx)(p,{size:14,"aria-hidden":`true`}),`Fit graph`]})]}),(0,O.jsxs)(`div`,{className:`graph-content`,children:[(0,O.jsxs)(`div`,{ref:S,className:`graph-visual`,"aria-label":`Interactive World graph`,children:[(0,O.jsx)(ne,{ref:x,projection:t,collapsedIds:s,selectedKey:e.selectedKey,matchedIds:A,conversationTargets:f,initialPrefs:i,fitOnMount:o,onSelect:N,onActivate:e.onGraphOpenTerminal,onToggleCollapse:P,onViewChange:F}),(0,O.jsx)(`div`,{className:`graph-visual-help`,children:`Double-click a terminal to open it · drag nodes to pin · use zoom controls or scroll`}),t.omittedSpaceCount>0?(0,O.jsxs)(`div`,{className:`graph-overflow-badge`,children:[`+`,t.omittedSpaceCount,` spaces outside presentation bound`]}):null]}),(0,O.jsxs)(`aside`,{className:`graph-semantic`,"aria-label":`Graph semantic view`,children:[(0,O.jsx)(`div`,{className:`graph-semantic-head`,children:(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`strong`,{children:`Projects and spaces`}),(0,O.jsx)(`span`,{"aria-live":`polite`,children:u.trim()?`${j.length} matching spaces`:`${t.spaces.length} presented spaces`})]})}),M?(0,O.jsx)(ye,{node:M,onOpenTerminal:()=>e.onGraphOpenTerminal(M),onOpenInSpaces:()=>e.onGraphOpenInSpaces(M)}):(0,O.jsx)(`p`,{className:`graph-details-empty`,children:`Select a space or terminal to inspect it.`}),(0,O.jsx)(`ul`,{className:`graph-tree`,"aria-label":`Presented projects, spaces, and terminals`,children:j.map(t=>(0,O.jsx)(ve,{space:t,collapsed:s.has(t.node.id),selectedKey:e.selectedKey,matches:A,queryActive:!!u.trim(),onToggle:()=>P(t.node.id),onSelect:t=>e.onGraphSelect(t.selectionKey,t.hostKey),onOpenTerminal:e.onGraphOpenTerminal,onOpenInSpaces:e.onGraphOpenInSpaces,setButtonRef:re},t.node.id))}),j.length===0?(0,O.jsx)(`p`,{className:`graph-empty`,children:`No presented spaces match this search.`}):null,t.omittedSpaceCount>0?(0,O.jsxs)(`p`,{className:`graph-semantic-overflow`,children:[t.omittedSpaceCount,` additional `,Se(t.omittedSpaceCount,`space`,`spaces`),` omitted by the 128-space presentation bound.`]}):null,e.handoffStatus?(0,O.jsx)(`p`,{className:`world-handoff-status`,role:`status`,children:e.handoffStatus}):null]})]})]})}function ve({space:e,collapsed:t,selectedKey:n,matches:r,queryActive:i,onToggle:a,onSelect:o,onOpenTerminal:s,onOpenInSpaces:l,setButtonRef:u}){let d=i?e.terminals.filter(({id:e})=>r?.has(e)):e.terminals;return(0,O.jsxs)(`li`,{className:`graph-tree-space`,"data-status":Z(e.node),children:[(0,O.jsxs)(`div`,{className:`graph-tree-row`,children:[(0,O.jsx)(`button`,{className:`graph-collapse`,type:`button`,"aria-label":`${t?`Expand`:`Collapse`} ${e.node.label}`,"aria-expanded":!t,onClick:a,children:(0,O.jsx)(c,{size:14,"aria-hidden":`true`})}),(0,O.jsxs)(`button`,{ref:t=>u(e.node.selectionKey,t),className:`graph-tree-select`,type:`button`,"aria-pressed":n===e.node.selectionKey,onClick:()=>o(e.node),children:[(0,O.jsx)(`span`,{className:`graph-status-symbol`,"aria-hidden":`true`,children:Q(e.node)}),(0,O.jsxs)(`span`,{children:[(0,O.jsx)(`strong`,{children:e.node.label}),(0,O.jsx)(`small`,{children:$(e.node)})]})]}),e.node.actionable?(0,O.jsx)(`button`,{className:`graph-tree-open`,type:`button`,onClick:()=>l(e.node),children:`Open in Spaces`}):null]}),t?null:(0,O.jsxs)(`ul`,{"aria-label":`Terminals in ${e.node.label}`,children:[d.map(e=>(0,O.jsxs)(`li`,{"data-status":Z(e),children:[(0,O.jsxs)(`button`,{ref:t=>u(e.selectionKey,t),className:`graph-tree-select graph-tree-terminal`,type:`button`,"aria-pressed":n===e.selectionKey,"aria-label":`${e.label}, ${e.agentRunning?`agent terminal`:`empty shell`}: ${$(e)}. Double-click to open terminal.`,onClick:()=>o(e),onDoubleClick:()=>e.actionable&&s(e),children:[(0,O.jsx)(X,{node:e}),(0,O.jsxs)(`span`,{children:[(0,O.jsx)(`strong`,{children:e.label}),(0,O.jsx)(`small`,{children:$(e)})]})]}),e.actionable?(0,O.jsxs)(`span`,{className:`graph-tree-actions`,children:[(0,O.jsx)(`button`,{className:`graph-tree-open`,type:`button`,onClick:()=>s(e),children:`Open terminal`}),(0,O.jsx)(`button`,{className:`graph-tree-open`,type:`button`,onClick:()=>l(e),children:`Open in Spaces`})]}):null]},e.id)),e.terminals.length===0?(0,O.jsx)(`li`,{className:`graph-tree-empty`,children:`No attached terminals`}):null,e.omittedTerminalCount>0?(0,O.jsxs)(`li`,{className:`graph-tree-overflow`,children:[e.omittedTerminalCount,` additional `,Se(e.omittedTerminalCount,`terminal`,`terminals`),` omitted by the per-space bound.`]}):null]})]})}function ye({node:e,onOpenTerminal:t,onOpenInSpaces:n}){return(0,O.jsxs)(`section`,{className:`graph-details`,"aria-label":`Selected Graph entity`,children:[(0,O.jsxs)(`div`,{children:[e.kind===`terminal`?(0,O.jsx)(X,{node:e}):(0,O.jsx)(`span`,{className:`graph-status-symbol`,"aria-hidden":`true`,children:Q(e)}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`strong`,{children:e.label}),(0,O.jsxs)(`span`,{children:[e.kind===`space`?`Space`:e.agentRunning?`Agent terminal`:`Empty shell`,` · `,$(e)]})]})]}),e.taskSummary?(0,O.jsx)(`p`,{children:e.taskSummary}):null,(0,O.jsxs)(`dl`,{children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`dt`,{children:`Host`}),(0,O.jsx)(`dd`,{children:e.hostLabel})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`dt`,{children:`Status`}),(0,O.jsx)(`dd`,{children:Z(e)})]}),e.stale?(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`dt`,{children:`Snapshot`}),(0,O.jsx)(`dd`,{children:xe(e)})]}):null,e.subtitle?(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`dt`,{children:`Project`}),(0,O.jsx)(`dd`,{children:e.subtitle})]}):null,e.modelLabel?(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`dt`,{children:`Agent`}),(0,O.jsx)(`dd`,{children:e.modelLabel})]}):null]}),e.actionable?(0,O.jsxs)(`div`,{className:`graph-details-actions`,children:[e.kind===`terminal`?(0,O.jsx)(`button`,{className:`btn btn-primary`,type:`button`,onClick:t,children:`Open terminal`}):null,(0,O.jsx)(`button`,{className:e.kind===`space`?`btn btn-primary`:`btn`,type:`button`,onClick:n,children:`Open in Spaces`})]}):(0,O.jsx)(`span`,{className:`graph-action-unavailable`,children:`Open in Spaces unavailable`})]})}function X({node:e}){return(0,O.jsxs)(`span`,{className:`graph-terminal-identity`,"data-agent-kind":e.agentKind??(e.agentRunning?`unknown`:`shell`),title:e.agentRunning?e.modelLabel??e.label:`Empty shell`,"aria-hidden":`true`,children:[e.agentKind?(0,O.jsx)(o,{kind:e.agentKind}):e.agentRunning?(0,O.jsx)(m,{size:16}):(0,O.jsx)(s,{size:16}),(0,O.jsx)(`span`,{className:`graph-terminal-status`,children:Q(e)})]})}function be(e,t){let n=t.trim().toLocaleLowerCase();if(!n)return null;let r=new Set;for(let t of e){if(t.node.searchText.includes(n)){r.add(t.node.id);for(let e of t.terminals)r.add(e.id);continue}for(let e of t.terminals)e.searchText.includes(n)&&(r.add(t.node.id),r.add(e.id))}return r}function Z(e){return e.disconnected?`disconnected`:e.status}function Q(e){return e.stale?`⏸`:e.status===`working`?`▶`:e.status===`blocked`?`!`:e.status===`done`?`✓`:e.status===`idle`?`○`:`?`}function $(e){let t=[Z(e),e.stale?xe(e):null,e.focused?`focused`:null];return e.kind===`space`?t.push(e.hostLabel,e.subtitle??null):t.push(e.agentRunning?`agent running`:`empty shell`,e.stateLabel??null,e.modelLabel??null),t.filter(Boolean).join(` · `)}function xe(e){return`${e.connectionState} · stale`}function Se(e,t,n){return e===1?t:n}export{ge as default,be as graphMatches};
|