Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@arancini/systems

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arancini/systems - npm Package Compare versions

Comparing version 5.0.0 to 5.0.1

12

dist/executor.d.ts

@@ -13,4 +13,14 @@ import { AnyEntity, Query, QueryDescription, World } from '@arancini/core';

constructor(world: World<E>);
/**
* Initialises the Executor. Must be called before update.
*/
init(): void;
/**
* Updates all systems
* @param delta optional delta time
*/
update(delta?: number): void;
/**
* Calls onDestroy on all systems
*/
destroy(): void;

@@ -20,3 +30,3 @@ /**

* @param clazz the System class
* @returns the System, or undefined if it is not registerd
* @returns the System, or undefined if it is not present
*/

@@ -23,0 +33,0 @@ get<S extends System>(clazz: SystemClass<S>): S | undefined;

2

dist/index.es.js

@@ -1,2 +0,2 @@

class t{world;initialised=!1;time=0;get systems(){return Array.from(this.systemClassToInstance.values())}systemClassToInstance=new Map;systemsToUpdate=[];systemCounter=0;systemAttachments=new Map;constructor(t){this.world=t}init(){this.initialised=!0;for(const t of this.systemClassToInstance.values())this.initSystem(t);this.sortSystems()}update(t=0){this.time+=t;for(let s=0;s<this.systemsToUpdate.length;s++){const e=this.systemsToUpdate[s];e.enabled&&(e.__internal.requiredQueries.length>0&&e.__internal.requiredQueries.some((t=>0===t.entities.length))||e.onUpdate(t,this.time))}}destroy(){for(const t of this.systemClassToInstance.values())t.onDestroy()}get(t){return this.systemClassToInstance.get(t)}add(t,s){if(this.systemClassToInstance.has(t))throw new Error(`System "${t.name}" has already been registered`);this.systemCounter++;const e=new t(this);this.systemClassToInstance.set(t,e),e.__internal.class=t,e.__internal.priority=s?.priority??0,e.__internal.order=this.systemCounter,this.initSingletonQueries(e),this.updateAllSystemAttachments();const n=(i=t,r="onUpdate",Object.getOwnPropertyNames(i.prototype).includes(r));var i,r;return n&&this.systemsToUpdate.push(e),this.initialised&&(this.initSystem(e),n&&this.sortSystems()),this}remove(t){const s=this.systemClassToInstance.get(t);if(!s)throw new Error(`System "${t.name}" is not registered`);return this.systemClassToInstance.delete(t),this.systemsToUpdate=this.systemsToUpdate.filter((s=>s.__internal.class!==t)),s.__internal.queries.forEach((t=>{this.world.destroyQuery(t,s)})),s.__internal.requiredQueries=[],s.onDestroy(),this.updateAllSystemAttachments(),this}initSystem(t){t.onInit()}initSingletonQueries(t){for(const e in t){const n=t,i=n[e];if(i?.__internal?.systemSingletonPlaceholder){const{__internal:{component:r,options:o}}=i,a=t=>t.has(r),l=s(this.world,t,a,o),h=()=>{n[e]=l.first?.[r]};l.onEntityAdded.add(h),l.onEntityRemoved.add(h),h()}}}updateSystemAttachments(t){for(const s in t){const e=t[s];if(e?.__internal?.attachedSystemPlaceholder){const n=this.systemAttachments.get(t)??[];n.push({field:s,systemClass:e.__internal.systemClass}),this.systemAttachments.set(t,n);const{__internal:{systemClass:i}}=e;t[s]=this.get(i)}}const s=this.systemAttachments.get(t)??[];for(const{field:e,systemClass:n}of s)t[e]=this.get(n)}updateAllSystemAttachments(){for(const t of this.systemClassToInstance.values())this.updateSystemAttachments(t)}sortSystems(){this.systemsToUpdate.sort(((t,s)=>s.__internal.priority-t.__internal.priority||t.__internal.order-s.__internal.order))}}const s=(t,s,e,n)=>{const i=t.query(e,{owner:s});return n?.required&&s.__internal.requiredQueries.push(i),i};class e{enabled=!0;executor;world;__internal={class:null,queries:new Set,priority:0,order:0,requiredQueries:[]};constructor(t){this.executor=t,this.world=t.world}onDestroy(){}onInit(){}onUpdate(t,s){}unregister(){this.executor.remove(this.__internal.class)}query(t,e){return s(this.executor.world,this,t,e)}singleton(t,s){return{__internal:{systemSingletonPlaceholder:!0,component:t,options:s}}}attach(t){return{__internal:{attachedSystemPlaceholder:!0,systemClass:t}}}}export{t as Executor,e as System};
class t{world;initialised=!1;time=0;get systems(){return Array.from(this.systemClassToInstance.values())}systemClassToInstance=new Map;systemsToUpdate=[];systemCounter=0;systemAttachments=new Map;constructor(t){this.world=t}init(){this.initialised=!0;for(const t of this.systemClassToInstance.values())this.initSystem(t);this.sortSystems()}update(t=0){this.time+=t;for(let s=0;s<this.systemsToUpdate.length;s++){const e=this.systemsToUpdate[s];e.enabled&&(e.__internal.requiredQueries.length>0&&e.__internal.requiredQueries.some((t=>0===t.entities.length))||e.onUpdate(t,this.time))}}destroy(){for(const t of this.systemClassToInstance.values())t.onDestroy()}get(t){return this.systemClassToInstance.get(t)}add(t,s){if(this.systemClassToInstance.has(t))throw new Error(`System "${t.name}" has already been registered`);this.systemCounter++;const e=new t(this);this.systemClassToInstance.set(t,e),e.__internal.class=t,e.__internal.priority=s?.priority??0,e.__internal.order=this.systemCounter,this.initSingletonQueries(e),this.updateAllSystemAttachments();const n=(i=t,r="onUpdate",Object.getOwnPropertyNames(i.prototype).includes(r));var i,r;return n&&this.systemsToUpdate.push(e),this.initialised&&(this.initSystem(e),n&&this.sortSystems()),this}remove(t){const s=this.systemClassToInstance.get(t);if(!s)throw new Error(`System "${t.name}" is not registered`);return this.systemClassToInstance.delete(t),this.systemsToUpdate=this.systemsToUpdate.filter((s=>s.__internal.class!==t)),s.__internal.queries.forEach((t=>{this.world.destroyQuery(t,s)})),s.__internal.requiredQueries=[],s.onDestroy(),this.updateAllSystemAttachments(),this}initSystem(t){t.onInit()}initSingletonQueries(t){for(const e in t){const n=t,i=n[e];if(i?.__internal?.systemSingletonPlaceholder){const{__internal:{component:r,options:o}}=i,a=t=>t.has(r),l=s(this.world,t,a,o),h=()=>{n[e]=l.first?.[r]};l.onEntityAdded.add(h),l.onEntityRemoved.add(h),h()}}}updateSystemAttachments(t){for(const s in t){const e=t[s];if(e?.__internal?.attachedSystemPlaceholder){const n=this.systemAttachments.get(t)??[];n.push({field:s,systemClass:e.__internal.systemClass}),this.systemAttachments.set(t,n);const{__internal:{systemClass:i}}=e;t[s]=this.get(i)}}const s=this.systemAttachments.get(t)??[];for(const{field:e,systemClass:n}of s)t[e]=this.get(n)}updateAllSystemAttachments(){for(const t of this.systemClassToInstance.values())this.updateSystemAttachments(t)}sortSystems(){this.systemsToUpdate.sort(((t,s)=>s.__internal.priority-t.__internal.priority||t.__internal.order-s.__internal.order))}}const s=(t,s,e,n)=>{const i=t.query(e,{handle:s});return s.__internal.queries.add(i),n?.required&&s.__internal.requiredQueries.push(i),i};class e{enabled=!0;executor;world;__internal={class:null,queries:new Set,priority:0,order:0,requiredQueries:[]};constructor(t){this.executor=t,this.world=t.world}onDestroy(){}onInit(){}onUpdate(t,s){}unregister(){this.executor.remove(this.__internal.class)}query(t,e){return s(this.executor.world,this,t,e)}singleton(t,s){return{__internal:{systemSingletonPlaceholder:!0,component:t,options:s}}}attach(t){return{__internal:{attachedSystemPlaceholder:!0,systemClass:t}}}}export{t as Executor,e as System};
//# sourceMappingURL=index.es.js.map

@@ -68,3 +68,3 @@ import type { AnyEntity, Query, QueryDescription, World } from '@arancini/core';

*/
queries: Set<Query<E>>;
queries: Set<Query<any>>;
/**

@@ -71,0 +71,0 @@ * The priority of the system, determines system run order.

@@ -12,3 +12,3 @@ {

"license": "MIT",
"version": "5.0.0",
"version": "5.0.1",
"homepage": "https://github.com/isaac-mason/arancini",

@@ -25,3 +25,3 @@ "bugs": {

"dependencies": {
"@arancini/core": "5.0.0"
"@arancini/core": "5.0.1"
},

@@ -28,0 +28,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc