Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Designed aiming to achieve a "pure" ECS implementation, following two main rules:
world
instanceworld
npm install --save ecsy
Warning: Highly experimental API subject to change every day :)
import {World, System, ReactiveSystem} from 'ecs';
// Rotating component
class Rotating {
constructor() {
this.rotatingSpeed = 0.1;
this.decreasingSpeed = 0.001;
}
}
// Transform component
class Transform {
constructor() {
this.rotation = { x: 0, y: 0, z: 0 };
this.position = { x: 0, y: 0, z: 0 };
this.scale = { x: 1, y: 1, z: 1 };
}
}
// Mouse component (to be used as singleton)
class MouseState {
constructor() {
this.mouseDown = false;
}
}
// Create a TestSystem to modify Transform components
class RotatingSystem extends System {
init() {
return {
queries: {
entities: { components: [Rotating, Transform] }
}
};
}
execute(delta) {
let entities = this.queries.entities;
for (var i = 0; i < entities.length; i++) {
var entity = entities[i];
var rotating = entity.getComponent(Rotating);
var rotatingSpeed = rotating.rotatingSpeed;
var transform = entity.getMutableComponent(Transform);
transform.rotation.x += rotatingSpeed;
}
}
}
// Create a TestSystem
class MouseSystem extends System {
init() {
var mouseState = this.world.components.mouseState;
window.addEventListener('mousedown', () => {
mouseState.mouseDown = true;
});
window.addEventListener('mouseup', () => {
mouseState.mouseDown = false;
});
}
}
// Create a reactive system
class ReactiveSystem extends System {
init() {
return {
queries: {
entities: {
components: [Rotating, Transform]
events: {
added: {
event: "EntityAdded"
},
removed: {
event: "EntityRemoved"
},
changed: {
event: "EntityChanged"
},
rotatingChanged: {
event: "ComponentChanged",
components: [Rotating]
},
transformChanged: {
event: "ComponentChanged",
components: [Transform]
}
}
}
}
};
}
execute() {
console.log('OnAdded', this.events.entities.added);
console.log('OnRemoved', this.events.entities.removed);
console.log('OnChanged entities', this.events.entities.changed);
console.log('OnChanged Rotating Component', this.events.entities.rotatingChanged);
console.log('OnChanged Transform Component', this.events.entities.transformChanged);
}
}
// Create a world and register all the elements on it
var world = new World();
world
.registerComponent(Rotating)
.registerComponent(Transform)
.registerSingletonComponent(MouseState);
world
.registerSystem(RotatingSystem)
.registerSystem(MouseSystem);
var entity = world.createEntity();
entity
.addComponent(Rotating, {rotationSpeed: 0.2})
.addComponent(Transform);
// Update systems per frame
var previousTime = performance.now();
function update() {
var time = performance.now();
var delta = time - previousTime;
previousTime = time;
world.execute(delta, time);
requestAnimationFrame(update);
}
requestAnimationFrame(update);
FAQs
Entity Component System in JS
We found that ecsy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.