blade-code 0.10.163 → 0.10.165
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/blade.js +2 -2
- package/dist/{chunk-dj17zw92.js → chunk-10pj0g1r.js} +1 -1
- package/dist/{chunk-wysmzs8h.js → chunk-1wmcyagp.js} +1 -1
- package/dist/chunk-3wx9aq8m.js +1 -0
- package/dist/{chunk-7eexcvd6.js → chunk-3yx1z7vq.js} +2 -2
- package/dist/{chunk-ydfqzfy5.js → chunk-51crjjt1.js} +1 -1
- package/dist/chunk-55z8nm23.js +1 -0
- package/dist/{chunk-tmxh9cds.js → chunk-6knxtdzn.js} +5 -5
- package/dist/{chunk-wwsax8zw.js → chunk-6tgjente.js} +1 -1
- package/dist/{chunk-xeyhp68m.js → chunk-708ja5cz.js} +1 -1
- package/dist/{chunk-xp4zfqxh.js → chunk-73vr1br7.js} +1 -1
- package/dist/{chunk-8bb421cb.js → chunk-82sdv0yv.js} +1 -1
- package/dist/{chunk-bztcgtpv.js → chunk-8eqs5drs.js} +1 -1
- package/dist/{chunk-2w6hbep9.js → chunk-911n2w2b.js} +1 -1
- package/dist/{chunk-76vtq1we.js → chunk-9430yx31.js} +1 -1
- package/dist/{chunk-h0d4154v.js → chunk-c5ncj6se.js} +1 -1
- package/dist/{chunk-hm1tp7jr.js → chunk-dzgj64vq.js} +1 -1
- package/dist/{chunk-682e101s.js → chunk-dzhkr1h0.js} +1 -1
- package/dist/{chunk-mgw83hkv.js → chunk-e394p3sh.js} +1 -1
- package/dist/{chunk-zew66zhx.js → chunk-g570p5bh.js} +1 -1
- package/dist/{chunk-jaxpzavy.js → chunk-h1cs69np.js} +1 -1
- package/dist/{chunk-wysx2q8e.js → chunk-hnnsqhgg.js} +1 -1
- package/dist/{chunk-qyj9khsj.js → chunk-md7px7ha.js} +1 -1
- package/dist/{chunk-gsrx4w3v.js → chunk-ndhdrtef.js} +1 -1
- package/dist/{chunk-qskr05jh.js → chunk-p505ms9g.js} +1 -1
- package/dist/{chunk-f3n2hyxk.js → chunk-r3fke6yp.js} +1 -1
- package/dist/{chunk-xabj78vm.js → chunk-sg580v6q.js} +1 -1
- package/dist/{chunk-jzvnjrj9.js → chunk-tgxa39ay.js} +2 -2
- package/dist/{chunk-1zgqrzfv.js → chunk-vmckpv2t.js} +1 -1
- package/dist/{chunk-2b1f5rwp.js → chunk-wa3sdw3c.js} +1 -1
- package/dist/{chunk-73gr1w7q.js → chunk-wac2a806.js} +1 -1
- package/dist/{chunk-xhg70jby.js → chunk-whbp683s.js} +1 -1
- package/dist/{chunk-4t5hhrwt.js → chunk-wkyw8ban.js} +1 -1
- package/dist/{chunk-60ggtcfe.js → chunk-xde27z0w.js} +1 -1
- package/dist/{chunk-zgtned44.js → chunk-ye0ev131.js} +1 -1
- package/dist/{chunk-30tn6r05.js → chunk-yq3982gr.js} +1 -1
- package/dist/{chunk-1ak6q7tt.js → chunk-za40abdc.js} +1 -1
- package/dist/{chunk-qfpgms8w.js → chunk-zrnzpknv.js} +2 -2
- package/dist/{chunk-158zwy3s.js → chunk-zw8q8dye.js} +1 -1
- package/package.json +1 -1
- package/dist/chunk-1vxc7qxm.js +0 -1
- package/dist/chunk-93b8x5s0.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Ai as H,Bi as I}from"./chunk-
|
|
1
|
+
import{Ai as H,Bi as I}from"./chunk-wa3sdw3c.js";import{Mutex as J}from"async-mutex";class B extends Error{limit;resource="resident_runtimes";retryable=!0;constructor(b){super("Session runtime capacity is full");this.limit=b;this.name="SessionRuntimeCapacityError"}}class D extends Error{constructor(){super("Session runtime residency is closed");this.name="SessionRuntimeResidencyClosedError"}}class A extends Error{constructor(b){super(`Session runtime residency already owns key: ${b}`);this.name="SessionRuntimeResidencyConflictError"}}class K{maxResident;idleMs;now;residents=new Map;reservations=new Map;operations=new J;nextGeneration=1;closed=!1;constructor(b){if(!H(b.maxResident))throw Error("Invalid max resident Session Runtime limit");if(!I(b.idleMs))throw Error("Invalid Session Runtime idle timeout");this.maxResident=b.maxResident,this.idleMs=b.idleMs,this.now=b.now??Date.now}acquire(b){let j=this.residents.get(b);if(!j||j.poisoned)return;return j.pins++,j.lastUsedAt=this.now(),this.createLease(j)}owns(b,j){let q=this.residents.get(b);return Boolean(q&&(j===void 0||q.value===j))}async reserve(b,j){if(!b.trim())throw Error("Session runtime residency key must not be blank");return this.operations.runExclusive(async()=>{if(this.closed)throw new D;if(this.residents.has(b)||this.reservations.has(b))throw new A(b);while(this.retainedCount()>=this.maxResident){if(!j.allowEviction)throw new B(this.maxResident);let z=this.oldestEvictableWebResident();if(!z)throw new B(this.maxResident);await this.disposeResident(z,!0)}let q={generation:this.allocateGeneration(),surface:j.surface};return this.reservations.set(b,q),this.createReservation(b,q)})}async remove(b,j){return this.operations.runExclusive(async()=>{let q=this.residents.get(b);if(!q||j!==void 0&&q.value!==j)return!1;if(q.pins>0)return!1;return await this.disposeResident(q,!0),!0})}async forget(b,j){return this.operations.runExclusive(async()=>{let q=this.residents.get(b);if(!q||j!==void 0&&q.value!==j||q.pins>0)return!1;return this.residents.delete(b),!0})}async sweepIdle(){return this.operations.runExclusive(async()=>{if(this.closed)return 0;let b=0;while(!0){let j=this.oldestIdleWebResident();if(!j)return b;await this.disposeResident(j,!0),b++}})}async disposeAll(){await this.operations.runExclusive(async()=>{this.closed=!0,this.reservations.clear();let b;for(let j of[...this.residents.values()])try{await this.disposeResident(j,!1)}catch(q){b??=q}if(this.residents.clear(),b!==void 0)throw b})}getStats(){let b=0;for(let j of this.residents.values())if(j.pins>0)b++;return{resident:this.residents.size,reserved:this.reservations.size,pinned:b,maxResident:this.maxResident}}retainedCount(){return this.residents.size+this.reservations.size}allocateGeneration(){let b=this.nextGeneration;return this.nextGeneration=this.nextGeneration===Number.MAX_SAFE_INTEGER?1:this.nextGeneration+1,b}createReservation(b,j){let q=!1;return{commit:(z)=>{if(q)throw new A(b);if(z.key!==b||z.surface!==j.surface||this.reservations.get(b)!==j||this.closed)throw this.reservations.delete(b),q=!0,this.closed?new D:new A(b);this.reservations.delete(b);let G={...z,generation:j.generation,pins:1,lastUsedAt:this.now(),poisoned:!1};return this.residents.set(b,G),q=!0,this.createLease(G)},cancel:()=>{if(q)return;if(this.reservations.get(b)===j)this.reservations.delete(b);q=!0}}}createLease(b){let j=!1;return{value:b.value,release:()=>{if(j)return;j=!0;let q=this.residents.get(b.key);if(q!==b||q.generation!==b.generation)return;q.pins=Math.max(0,q.pins-1),q.lastUsedAt=this.now()}}}oldestEvictableWebResident(){return this.sortedWebResidents().find((b)=>this.canEvict(b))}oldestIdleWebResident(){let b=this.now();return this.sortedWebResidents().find((j)=>b-j.lastUsedAt>=this.idleMs&&this.canEvict(j))}sortedWebResidents(){return[...this.residents.values()].filter((b)=>b.surface==="web").sort((b,j)=>b.lastUsedAt-j.lastUsedAt||b.generation-j.generation)}canEvict(b){if(b.pins>0||b.poisoned)return!1;try{return b.canEvict()}catch{return!1}}async disposeResident(b,j){if(this.residents.get(b.key)!==b)return;this.residents.delete(b.key);try{await b.dispose()}catch(q){if(j&&!this.closed&&!this.residents.has(b.key))b.lastUsedAt=this.now(),b.poisoned=!0,this.residents.set(b.key,b);throw q}}}
|
|
2
2
|
export{B as v,K as w};
|