fix(security & perf): implement bearer session tokens, salted pbkdf2, object pooling and background caching

This commit is contained in:
Antigravity committed 2026-09-17 13:14:31 +00:00
1 parent 258b1a9cb1
commit 7cd0792799
15 files changed
+1264 -105

No files matched your search

+56 -1
View File
@@ -1,5 +1,20 @@
window.Projectile = class Projectile {
constructor(x, y, row, type = 'pea', vy = 0, damage = 20, isCrit = false, targetX = 750) {
this.pierceHits = new Set();
this.init(x, y, row, type, vy, damage, isCrit, targetX);
}
init(x, y, row, type = 'pea', vy = 0, damage = 20, isCrit = false, targetX = 750) {
if (typeof isCrit === 'number' && isCrit > 1 && typeof damage === 'number' && damage >= 100) {
targetX = damage;
damage = (typeof vy === 'number') ? vy : 80;
vy = 0;
isCrit = false;
} else if (typeof isCrit === 'number' && typeof damage === 'number' && isCrit >= 100) {
targetX = isCrit;
isCrit = false;
}
this.x = x;
this.y = y;
this.startX = x;
@@ -37,10 +52,15 @@ window.Projectile = class Projectile {
this.freezes = type === 'freeze_snowpea';
this.pierces = type === 'fume' || type === 'plasma';
this.maxPierces = type === 'plasma' ? 2 : 999;
this.pierceHits = new Set();
if (this.pierceHits) {
this.pierceHits.clear();
} else {
this.pierceHits = new Set();
}
this.lobProgress = 0;
this.toRemove = false;
this.animTime = 0;
this.hitCount = 0;
}
update(dt) {
@@ -212,3 +232,38 @@ window.Projectile = class Projectile {
ctx.restore();
}
};
// Reusable Object Pool for Projectiles (Eliminates GC churn & frame drops)
window.ProjectilePool = class ProjectilePool {
constructor(initialCapacity = 60) {
this.pool = [];
for (let i = 0; i < initialCapacity; i++) {
this.pool.push(new window.Projectile(0, 0, 0));
}
}
get(x, y, row, type = 'pea', vy = 0, damage = 20, isCrit = false, targetX = 750) {
const proj = this.pool.length > 0 ? this.pool.pop() : new window.Projectile(x, y, row, type, vy, damage, isCrit, targetX);
proj.init(x, y, row, type, vy, damage, isCrit, targetX);
return proj;
}
release(proj) {
if (!proj) return;
proj.toRemove = false;
if (proj.pierceHits) proj.pierceHits.clear();
this.pool.push(proj);
}
releaseAll(projectiles) {
if (!Array.isArray(projectiles)) return;
for (const p of projectiles) {
this.release(p);
}
}
clear() {
this.pool = [];
}
};