@inglorious/store
Advanced tools
+1
-1
| { | ||
| "name": "@inglorious/store", | ||
| "version": "9.4.0", | ||
| "version": "9.5.0", | ||
| "description": "A state manager for real-time, collaborative apps, inspired by game development patterns and compatible with Redux.", | ||
@@ -5,0 +5,0 @@ "author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)", |
+34
-28
@@ -33,3 +33,2 @@ import { create } from "mutative" | ||
| let state, eventMap, incomingEvents, isProcessing | ||
| reset() | ||
@@ -54,2 +53,3 @@ const baseStore = { | ||
| store._api = api | ||
| reset() | ||
| return store | ||
@@ -208,2 +208,9 @@ | ||
| } | ||
| if (autoCreateEntities && !state[typeName]) { | ||
| notify("add", { | ||
| id: typeName, | ||
| type: typeName, | ||
| }) | ||
| } | ||
| } | ||
@@ -226,26 +233,4 @@ | ||
| const oldEntities = state ?? {} | ||
| const newEntities = augmentEntities(nextState) | ||
| let newEntities = augmentEntities(nextState) | ||
| if (autoCreateEntities) { | ||
| for (const typeName of Object.keys(types)) { | ||
| // Check if entity already exists | ||
| const hasEntity = Object.values(newEntities).some( | ||
| (entity) => entity.type === typeName, | ||
| ) | ||
| if (!hasEntity) { | ||
| // No entity for this type → auto-create minimal entity | ||
| newEntities[typeName] = { | ||
| id: typeName, | ||
| type: typeName, | ||
| } | ||
| } | ||
| } | ||
| } | ||
| state = newEntities | ||
| eventMap = new EventMap(types, newEntities) | ||
| incomingEvents = [] | ||
| isProcessing = false | ||
| const oldEntityIds = new Set(Object.keys(oldEntities)) | ||
@@ -261,9 +246,30 @@ const newEntityIds = new Set(Object.keys(newEntities)) | ||
| state = oldEntities | ||
| eventMap = new EventMap(types, oldEntities) | ||
| incomingEvents = [] | ||
| isProcessing = false | ||
| entitiesToDestroy.forEach((id) => { | ||
| notify("remove", id) | ||
| }) | ||
| entitiesToCreate.forEach((id) => { | ||
| incomingEvents.push({ type: `#${id}:create` }) | ||
| const entity = newEntities[id] | ||
| notify("add", { id, ...entity }) | ||
| }) | ||
| entitiesToDestroy.forEach((id) => { | ||
| incomingEvents.push({ type: `#${id}:destroy` }) | ||
| }) | ||
| if (autoCreateEntities) { | ||
| for (const typeName of Object.keys(types)) { | ||
| const hasEntity = Object.values(state).some( | ||
| (entity) => entity.type === typeName, | ||
| ) | ||
| if (!hasEntity) { | ||
| notify("add", { | ||
| id: typeName, | ||
| type: typeName, | ||
| }) | ||
| } | ||
| } | ||
| } | ||
| } | ||
@@ -270,0 +276,0 @@ |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
112228
02293
0.22%