zeropoint-node 1.0.0 → 1.0.1

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.
Files changed (323) hide show
  1. package/README.md +38 -105
  2. package/dist/__tests__/api/ProductionAPI.test.js +20 -0
  3. package/dist/__tests__/artifacts/ArtifactRegistry.test.js +248 -0
  4. package/dist/__tests__/basic.test.js +104 -0
  5. package/dist/__tests__/config/constants.test.js +20 -0
  6. package/dist/__tests__/consciousness/ConsciousnessField.test.js +20 -0
  7. package/dist/__tests__/consciousness/SelfEvolvingConsciousness.test.js +185 -0
  8. package/dist/__tests__/core/AbstractField.test.js +81 -0
  9. package/dist/__tests__/core/CoilMixin.test.js +20 -0
  10. package/dist/__tests__/core/CoilSystem.test.js +20 -0
  11. package/dist/__tests__/core/ComplianceSystem.test.js +141 -0
  12. package/dist/__tests__/core/InfiniteDimensionalRefactor.test.js +258 -0
  13. package/dist/__tests__/core/LivingAdapter.test.js +31 -0
  14. package/dist/__tests__/core/MathUtils.test.js +20 -0
  15. package/dist/__tests__/core/NetworkNode.test.js +20 -0
  16. package/dist/__tests__/core/Observer.test.js +20 -0
  17. package/dist/__tests__/core/OperationRegistry.test.js +48 -0
  18. package/dist/__tests__/core/PatternRecognition.test.js +20 -0
  19. package/dist/__tests__/core/PatternRegistry.test.js +20 -0
  20. package/dist/__tests__/core/ScientificCompliance.test.js +58 -0
  21. package/dist/__tests__/core/SharedConstants.test.js +20 -0
  22. package/dist/__tests__/core/UnifiedMetaphysicalInterface.test.js +20 -0
  23. package/dist/__tests__/core/UnifiedSystem.test.js +20 -0
  24. package/dist/__tests__/core/UnifiedTypes.test.js +20 -0
  25. package/dist/__tests__/core/UnifiedVoidEquations.test.js +20 -0
  26. package/dist/__tests__/core/VortexMathAdapter.test.js +31 -0
  27. package/dist/__tests__/core/ZeroPoint.test.js +71 -0
  28. package/dist/__tests__/core/ZeroPointSystem.test.js +219 -0
  29. package/dist/__tests__/emergence/patterns.test.js +20 -0
  30. package/dist/__tests__/field/EmergenceLedger.test.js +20 -0
  31. package/dist/__tests__/field/ObserverAwareField.test.js +20 -0
  32. package/dist/__tests__/field/ResonanceConsensus.test.js +20 -0
  33. package/dist/__tests__/git-integration.test.js +201 -0
  34. package/dist/__tests__/globalSetup.js +80 -0
  35. package/dist/__tests__/globalTeardown.js +28 -0
  36. package/dist/__tests__/index.test.js +20 -0
  37. package/dist/__tests__/integration/ZeroPointIntegration.test.js +221 -0
  38. package/dist/__tests__/integrity/FieldIntegrity.test.js +20 -0
  39. package/dist/__tests__/knowledge/KnowledgeSystem.test.js +158 -0
  40. package/dist/__tests__/knowledge/KnowledgeSystemAnalysis.test.js +219 -0
  41. package/dist/__tests__/knowledge/KnowledgeSystemAutoGenerated.test.js +41 -0
  42. package/dist/__tests__/laws/MetaphysicalLawRegistry.test.js +183 -0
  43. package/dist/__tests__/living/LivingTestOrganism.js +246 -0
  44. package/dist/__tests__/living/LivingTestOrganism.test.js +124 -0
  45. package/dist/__tests__/math/AdvancedVBM.test.js +367 -0
  46. package/dist/__tests__/math/FlowerOfLife.test.js +344 -0
  47. package/dist/__tests__/math/FractalColorSystem.test.js +20 -0
  48. package/dist/__tests__/math/FractalMath.test.js +20 -0
  49. package/dist/__tests__/math/MathUtils.test.js +20 -0
  50. package/dist/__tests__/math/RodinCoil.test.js +20 -0
  51. package/dist/__tests__/math/ToroidalGeometry.test.js +20 -0
  52. package/dist/__tests__/math/VBM.test.js +538 -0
  53. package/dist/__tests__/math/VBMColorSystem.test.js +20 -0
  54. package/dist/__tests__/math/VortexMath.test.js +20 -0
  55. package/dist/__tests__/math/ZeroUnity.test.js +77 -0
  56. package/dist/__tests__/monitoring/HealthMonitor.test.js +20 -0
  57. package/dist/__tests__/performance/ZeroPointPerformance.test.js +371 -0
  58. package/dist/__tests__/physics/PlasmaCosmology.test.js +155 -0
  59. package/dist/__tests__/pwa/ConsciousnessPWA.test.js +20 -0
  60. package/dist/__tests__/qa/AutoGeneratedFromQA.test.js +195 -0
  61. package/dist/__tests__/qa/QAAsSourceOfTruth.test.js +69 -0
  62. package/dist/__tests__/setup.js +132 -0
  63. package/dist/__tests__/simple.test.js +51 -0
  64. package/dist/__tests__/stimulus/Application.test.js +272 -0
  65. package/dist/__tests__/stimulus/BaseController.test.js +198 -0
  66. package/dist/__tests__/stimulus/ControllerUtils.test.js +316 -0
  67. package/dist/__tests__/stimulus/MetaphysicalController.test.js +310 -0
  68. package/dist/__tests__/stimulus/ZeroPointController.test.js +252 -0
  69. package/dist/__tests__/training/ConsciousnessTrainingModel.test.js +335 -0
  70. package/dist/__tests__/types/DeviceConfig.test.js +20 -0
  71. package/dist/__tests__/types/UnifiedExports.test.js +20 -0
  72. package/dist/__tests__/unity/FieldUnity.test.js +20 -0
  73. package/dist/__tests__/utils/Cache.test.js +20 -0
  74. package/dist/__tests__/utils/GitIntegration.test.js +20 -0
  75. package/dist/__tests__/utils/Logger.test.js +20 -0
  76. package/dist/__tests__/utils/ResourceCleanup.test.js +20 -0
  77. package/dist/__tests__/utils/errorSimulator.js +40 -0
  78. package/dist/__tests__/utils/goldenRatioCache.js +36 -0
  79. package/dist/__tests__/void/VoidSystem.test.js +427 -0
  80. package/dist/api/ProductionAPI.js +313 -0
  81. package/dist/artifacts/ArtifactRegistry.js +122 -0
  82. package/dist/artifacts/CrystalArtifacts.js +106 -0
  83. package/dist/artifacts/MetaphysicalArtifact.js +75 -0
  84. package/dist/browser-standalone.js +191 -0
  85. package/dist/browser.js +157 -0
  86. package/dist/config/constants.js +57 -0
  87. package/dist/consciousness/ConsciousnessField.js +55 -0
  88. package/dist/consciousness/SelfEvolvingConsciousness.js +303 -0
  89. package/dist/core/AbstractField.js +30 -0
  90. package/dist/core/BrowserNetworkNode.js +309 -0
  91. package/dist/core/CoilMixin.js +216 -0
  92. package/dist/core/CoilSystem.js +204 -0
  93. package/dist/core/ComplianceSystem.js +291 -0
  94. package/dist/core/Dimension.js +2 -0
  95. package/dist/core/DimensionRegistry.js +141 -0
  96. package/dist/core/Field.js +2 -0
  97. package/dist/core/InfiniteDimensionalRefactor.js +389 -0
  98. package/dist/core/KnowledgeRegistry.js +273 -0
  99. package/dist/core/LivingAdapter.js +29 -0
  100. package/dist/core/MathUtils.js +297 -0
  101. package/dist/core/NetworkNode.js +348 -0
  102. package/dist/core/Observer.js +101 -0
  103. package/dist/core/Operation.js +59 -0
  104. package/dist/core/OperationRegistry.js +20 -0
  105. package/dist/core/Pattern.js +2 -0
  106. package/dist/core/PatternRecognition.js +493 -0
  107. package/dist/core/PatternRegistry.js +282 -0
  108. package/dist/core/ScientificCompliance.js +91 -0
  109. package/dist/core/SharedConstants.js +306 -0
  110. package/dist/core/UnifiedMetaphysicalInterface.js +533 -0
  111. package/dist/core/UnifiedSystem.js +317 -0
  112. package/dist/core/UnifiedTypes.js +5 -0
  113. package/dist/core/UnifiedVoidEquations.js +605 -0
  114. package/dist/core/VoidMatterConstants.js +9 -0
  115. package/dist/core/VortexMathAdapter.js +32 -0
  116. package/dist/core/ZeroPoint.js +971 -0
  117. package/dist/core/ZeroPointSystem.js +343 -0
  118. package/dist/core/applyLaws.js +12 -0
  119. package/dist/core/applyOperations.js +21 -0
  120. package/dist/devices/DeviceRegistry.js +151 -0
  121. package/dist/devices/ResonanceDevice.js +92 -0
  122. package/dist/devices/ResonanceDevices.js +139 -0
  123. package/dist/dimensions/Dimension.js +2 -0
  124. package/dist/emergence/AdvancedEmergence.js +930 -0
  125. package/dist/emergence/patterns.js +12 -0
  126. package/dist/field/EmergenceLedger.js +310 -0
  127. package/dist/field/ObserverAwareField.js +222 -0
  128. package/dist/field/ResonanceConsensus.js +330 -0
  129. package/dist/fields/Field.js +2 -0
  130. package/dist/geometry/MetatronsCube.js +28 -0
  131. package/dist/geometry/SacredGeometryPattern.js +15 -0
  132. package/dist/geometry/SacredGeometryRegistry.js +15 -0
  133. package/dist/geometry/__tests__/SacredGeometryRegistry.test.js +18 -0
  134. package/dist/index.js +232 -0
  135. package/dist/integrity/FieldIntegrity.js +237 -0
  136. package/dist/knowledge/KnowledgeSystem.js +938 -0
  137. package/dist/laws/MetaphysicalLaw.js +2 -0
  138. package/dist/laws/MetaphysicalLawRegistry.js +103 -0
  139. package/dist/laws/hermeticLaws.js +311 -0
  140. package/dist/math/AdvancedVBM.js +537 -0
  141. package/dist/math/FlowerOfLife.js +256 -0
  142. package/dist/math/FractalColorSystem.js +239 -0
  143. package/dist/math/FractalMath.js +187 -0
  144. package/dist/math/MathUtils.js +289 -0
  145. package/dist/math/RodinCoil.js +258 -0
  146. package/dist/math/ToroidalGeometry.js +230 -0
  147. package/dist/math/VBM.js +718 -0
  148. package/dist/math/VBMColorSystem.js +301 -0
  149. package/dist/math/VortexMath.js +170 -0
  150. package/dist/monitoring/HealthMonitor.js +297 -0
  151. package/dist/patterns/Pattern.js +2 -0
  152. package/dist/patterns/SacredGeometryRegistry.js +37 -0
  153. package/dist/physics/BlackHolePhysics.js +54 -0
  154. package/dist/physics/ConsciousnessPhysics.js +241 -0
  155. package/dist/physics/FractalUniverse.js +54 -0
  156. package/dist/physics/HolographicUniverse.js +54 -0
  157. package/dist/physics/PlasmaCosmology.js +134 -0
  158. package/dist/pwa/ConsciousnessPWA.js +300 -0
  159. package/dist/src/__tests__/globalTeardown.d.ts +10 -8
  160. package/dist/src/__tests__/globalTeardown.d.ts.map +1 -1
  161. package/dist/src/__tests__/globalTeardown.js +12 -71
  162. package/dist/src/__tests__/globalTeardown.js.map +1 -1
  163. package/dist/src/__tests__/living/LivingTestOrganism.d.ts +4 -0
  164. package/dist/src/__tests__/living/LivingTestOrganism.d.ts.map +1 -1
  165. package/dist/src/__tests__/living/LivingTestOrganism.js +8 -0
  166. package/dist/src/__tests__/living/LivingTestOrganism.js.map +1 -1
  167. package/dist/src/__tests__/utils/errorSimulator.d.ts +1 -1
  168. package/dist/src/__tests__/utils/goldenRatioCache.d.ts +1 -1
  169. package/dist/src/config/constants.d.ts +53 -0
  170. package/dist/src/config/constants.d.ts.map +1 -0
  171. package/dist/src/config/constants.js +58 -0
  172. package/dist/src/config/constants.js.map +1 -0
  173. package/dist/src/consciousness/ConsciousnessField.d.ts +42 -51
  174. package/dist/src/consciousness/ConsciousnessField.d.ts.map +1 -1
  175. package/dist/src/consciousness/ConsciousnessField.js +187 -200
  176. package/dist/src/consciousness/ConsciousnessField.js.map +1 -1
  177. package/dist/src/consciousness/SelfEvolvingConsciousness.d.ts +47 -18
  178. package/dist/src/consciousness/SelfEvolvingConsciousness.d.ts.map +1 -1
  179. package/dist/src/consciousness/SelfEvolvingConsciousness.js +151 -44
  180. package/dist/src/consciousness/SelfEvolvingConsciousness.js.map +1 -1
  181. package/dist/src/core/CoilMixin.d.ts +6 -6
  182. package/dist/src/core/CoilSystem.d.ts +6 -2
  183. package/dist/src/core/CoilSystem.d.ts.map +1 -1
  184. package/dist/src/core/CoilSystem.js +30 -21
  185. package/dist/src/core/CoilSystem.js.map +1 -1
  186. package/dist/src/core/InfiniteDimensionalRefactor.d.ts +145 -0
  187. package/dist/src/core/InfiniteDimensionalRefactor.d.ts.map +1 -0
  188. package/dist/src/core/InfiniteDimensionalRefactor.js +390 -0
  189. package/dist/src/core/InfiniteDimensionalRefactor.js.map +1 -0
  190. package/dist/src/core/NetworkNode.d.ts +3 -3
  191. package/dist/src/core/Observer.d.ts +12 -9
  192. package/dist/src/core/Observer.d.ts.map +1 -1
  193. package/dist/src/core/Observer.js +2 -2
  194. package/dist/src/core/Observer.js.map +1 -1
  195. package/dist/src/core/PatternRecognition.d.ts +63 -13
  196. package/dist/src/core/PatternRecognition.d.ts.map +1 -1
  197. package/dist/src/core/PatternRecognition.js +162 -88
  198. package/dist/src/core/PatternRecognition.js.map +1 -1
  199. package/dist/src/core/PatternRegistry.d.ts +99 -0
  200. package/dist/src/core/PatternRegistry.d.ts.map +1 -0
  201. package/dist/src/core/PatternRegistry.js +283 -0
  202. package/dist/src/core/PatternRegistry.js.map +1 -0
  203. package/dist/src/core/SharedConstants.d.ts +62 -9
  204. package/dist/src/core/SharedConstants.d.ts.map +1 -1
  205. package/dist/src/core/SharedConstants.js +83 -21
  206. package/dist/src/core/SharedConstants.js.map +1 -1
  207. package/dist/src/core/UnifiedMetaphysicalInterface.d.ts +173 -0
  208. package/dist/src/core/UnifiedMetaphysicalInterface.d.ts.map +1 -0
  209. package/dist/src/core/UnifiedMetaphysicalInterface.js +534 -0
  210. package/dist/src/core/UnifiedMetaphysicalInterface.js.map +1 -0
  211. package/dist/src/core/UnifiedSystem.d.ts +15 -12
  212. package/dist/src/core/UnifiedSystem.d.ts.map +1 -1
  213. package/dist/src/core/UnifiedSystem.js +5 -1
  214. package/dist/src/core/UnifiedSystem.js.map +1 -1
  215. package/dist/src/core/UnifiedTypes.d.ts +193 -0
  216. package/dist/src/core/UnifiedTypes.d.ts.map +1 -0
  217. package/dist/src/core/UnifiedTypes.js +6 -0
  218. package/dist/src/core/UnifiedTypes.js.map +1 -0
  219. package/dist/src/core/UnifiedVoidEquations.d.ts +3 -1
  220. package/dist/src/core/UnifiedVoidEquations.d.ts.map +1 -1
  221. package/dist/src/core/UnifiedVoidEquations.js +84 -0
  222. package/dist/src/core/UnifiedVoidEquations.js.map +1 -1
  223. package/dist/src/core/ZeroPoint.d.ts +101 -10
  224. package/dist/src/core/ZeroPoint.d.ts.map +1 -1
  225. package/dist/src/core/ZeroPoint.js +262 -18
  226. package/dist/src/core/ZeroPoint.js.map +1 -1
  227. package/dist/src/emergence/AdvancedEmergence.d.ts +19 -16
  228. package/dist/src/emergence/AdvancedEmergence.d.ts.map +1 -1
  229. package/dist/src/emergence/AdvancedEmergence.js +88 -52
  230. package/dist/src/emergence/AdvancedEmergence.js.map +1 -1
  231. package/dist/src/field/EmergenceLedger.d.ts +9 -18
  232. package/dist/src/field/EmergenceLedger.d.ts.map +1 -1
  233. package/dist/src/field/EmergenceLedger.js +9 -4
  234. package/dist/src/field/EmergenceLedger.js.map +1 -1
  235. package/dist/src/field/ObserverAwareField.d.ts +69 -65
  236. package/dist/src/field/ObserverAwareField.d.ts.map +1 -1
  237. package/dist/src/field/ObserverAwareField.js +158 -168
  238. package/dist/src/field/ObserverAwareField.js.map +1 -1
  239. package/dist/src/field/ResonanceConsensus.d.ts +4 -11
  240. package/dist/src/field/ResonanceConsensus.d.ts.map +1 -1
  241. package/dist/src/field/ResonanceConsensus.js +15 -10
  242. package/dist/src/field/ResonanceConsensus.js.map +1 -1
  243. package/dist/src/index.d.ts +5 -3
  244. package/dist/src/index.d.ts.map +1 -1
  245. package/dist/src/index.js +19 -4
  246. package/dist/src/index.js.map +1 -1
  247. package/dist/src/integrity/FieldIntegrity.d.ts +3 -8
  248. package/dist/src/integrity/FieldIntegrity.d.ts.map +1 -1
  249. package/dist/src/integrity/FieldIntegrity.js.map +1 -1
  250. package/dist/src/knowledge/KnowledgeSystem.d.ts +37 -55
  251. package/dist/src/knowledge/KnowledgeSystem.d.ts.map +1 -1
  252. package/dist/src/knowledge/KnowledgeSystem.js +281 -589
  253. package/dist/src/knowledge/KnowledgeSystem.js.map +1 -1
  254. package/dist/src/math/AdvancedVBM.d.ts +6 -6
  255. package/dist/src/math/FractalColorSystem.d.ts +1 -1
  256. package/dist/src/math/FractalColorSystem.js +3 -3
  257. package/dist/src/math/FractalColorSystem.js.map +1 -1
  258. package/dist/src/math/FractalMath.d.ts +9 -1
  259. package/dist/src/math/FractalMath.d.ts.map +1 -1
  260. package/dist/src/math/FractalMath.js +18 -5
  261. package/dist/src/math/FractalMath.js.map +1 -1
  262. package/dist/src/math/MathUtils.d.ts +3 -10
  263. package/dist/src/math/MathUtils.d.ts.map +1 -1
  264. package/dist/src/math/MathUtils.js +12 -20
  265. package/dist/src/math/MathUtils.js.map +1 -1
  266. package/dist/src/math/ToroidalGeometry.d.ts +1 -1
  267. package/dist/src/math/VBM.d.ts +2 -2
  268. package/dist/src/math/VortexMath.d.ts +1 -1
  269. package/dist/src/monitoring/HealthMonitor.d.ts +1 -1
  270. package/dist/src/monitoring/HealthMonitor.d.ts.map +1 -1
  271. package/dist/src/monitoring/HealthMonitor.js +29 -27
  272. package/dist/src/monitoring/HealthMonitor.js.map +1 -1
  273. package/dist/src/types/UnifiedExports.d.ts +4 -0
  274. package/dist/src/types/UnifiedExports.d.ts.map +1 -0
  275. package/dist/src/types/UnifiedExports.js +21 -0
  276. package/dist/src/types/UnifiedExports.js.map +1 -0
  277. package/dist/src/unity/FieldUnity.d.ts +1 -1
  278. package/dist/src/utils/Cache.d.ts +2 -2
  279. package/dist/src/utils/Cache.d.ts.map +1 -1
  280. package/dist/src/utils/Cache.js +7 -4
  281. package/dist/src/utils/Cache.js.map +1 -1
  282. package/dist/src/utils/GitIntegration.d.ts +1 -1
  283. package/dist/src/utils/Logger.d.ts +7 -7
  284. package/dist/src/utils/Logger.d.ts.map +1 -1
  285. package/dist/src/utils/Logger.js +5 -1
  286. package/dist/src/utils/Logger.js.map +1 -1
  287. package/dist/src/utils/ResourceCleanup.d.ts +33 -0
  288. package/dist/src/utils/ResourceCleanup.d.ts.map +1 -0
  289. package/dist/src/utils/ResourceCleanup.js +83 -0
  290. package/dist/src/utils/ResourceCleanup.js.map +1 -0
  291. package/dist/src/void/VoidSystem.d.ts +18 -18
  292. package/dist/stimulus/application.js +148 -0
  293. package/dist/stimulus/base/BaseController.js +141 -0
  294. package/dist/stimulus/controllers/MetaphysicalController.js +105 -0
  295. package/dist/stimulus/controllers/ZeroPointController.js +85 -0
  296. package/dist/stimulus/types/ControllerTypes.js +18 -0
  297. package/dist/stimulus/utils/ControllerUtils.js +192 -0
  298. package/dist/stimulus-entry.js +109 -0
  299. package/dist/training/ConsciousnessTrainingModel.js +301 -0
  300. package/dist/training/NeuralConsciousnessNetwork.js +311 -0
  301. package/dist/training/TrainingModelRegistry.js +243 -0
  302. package/dist/training/index.js +174 -0
  303. package/dist/types/DeviceConfig.js +29 -0
  304. package/dist/types/UnifiedExports.js +20 -0
  305. package/dist/unity/FieldUnity.js +325 -0
  306. package/dist/utils/BrowserCrypto.js +44 -0
  307. package/dist/utils/BrowserWebSocket.js +38 -0
  308. package/dist/utils/Cache.js +263 -0
  309. package/dist/utils/GitIntegration.js +127 -0
  310. package/dist/utils/Logger.js +249 -0
  311. package/dist/utils/ResourceCleanup.js +82 -0
  312. package/dist/utils/applyLaws.js +6 -0
  313. package/dist/void/VoidSystem.js +423 -0
  314. package/docs/API.md +176 -3
  315. package/docs/CONSCIOUSNESS_EXPANSION.md +369 -0
  316. package/docs/EVENT_HORIZON_METHODOLOGY.md +274 -0
  317. package/docs/FLOWER_OF_LIFE.md +300 -0
  318. package/docs/METAPHYSICAL.md +21 -1
  319. package/docs/METAPHYSICAL_DEBUGGING.md +493 -0
  320. package/docs/README.md +117 -15
  321. package/docs/TESTING_GUIDE.md +430 -0
  322. package/docs/UNIFIED_CREATORS.md +261 -0
  323. package/package.json +34 -64
@@ -0,0 +1,263 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resonanceCache = exports.vortexMathCache = exports.globalCache = exports.ResonanceCache = exports.VortexMathCache = exports.Cache = void 0;
4
+ class Cache {
5
+ constructor(config = {}) {
6
+ this.cache = new Map();
7
+ this.stats = {
8
+ hits: 0,
9
+ misses: 0,
10
+ sets: 0,
11
+ deletes: 0,
12
+ evictions: 0,
13
+ };
14
+ this.config = {
15
+ maxSize: 1000,
16
+ defaultTTL: 300000, // 5 minutes
17
+ cleanupInterval: 60000, // 1 minute
18
+ enableStats: true,
19
+ ...config,
20
+ };
21
+ // Don't start cleanup automatically - only start when explicitly requested
22
+ // this.startCleanup();
23
+ }
24
+ /**
25
+ * Set a value in the cache
26
+ */
27
+ set(key, value, ttl) {
28
+ const entry = {
29
+ key,
30
+ value,
31
+ timestamp: Date.now(),
32
+ ttl: ttl || this.config.defaultTTL,
33
+ accessCount: 0,
34
+ lastAccessed: Date.now(),
35
+ };
36
+ // Check if we need to evict entries
37
+ if (this.cache.size >= this.config.maxSize) {
38
+ this.evictLRU();
39
+ }
40
+ this.cache.set(key, entry);
41
+ this.stats.sets++;
42
+ }
43
+ /**
44
+ * Get a value from the cache
45
+ */
46
+ get(key) {
47
+ const entry = this.cache.get(key);
48
+ if (!entry) {
49
+ this.stats.misses++;
50
+ return null;
51
+ }
52
+ // Check if entry has expired
53
+ if (this.isExpired(entry)) {
54
+ this.cache.delete(key);
55
+ this.stats.misses++;
56
+ return null;
57
+ }
58
+ // Update access statistics
59
+ entry.accessCount++;
60
+ entry.lastAccessed = Date.now();
61
+ this.stats.hits++;
62
+ return entry.value;
63
+ }
64
+ /**
65
+ * Check if a key exists in the cache
66
+ */
67
+ has(key) {
68
+ const entry = this.cache.get(key);
69
+ if (!entry)
70
+ return false;
71
+ if (this.isExpired(entry)) {
72
+ this.cache.delete(key);
73
+ return false;
74
+ }
75
+ return true;
76
+ }
77
+ /**
78
+ * Delete a value from the cache
79
+ */
80
+ delete(key) {
81
+ const deleted = this.cache.delete(key);
82
+ if (deleted) {
83
+ this.stats.deletes++;
84
+ }
85
+ return deleted;
86
+ }
87
+ /**
88
+ * Clear all entries from the cache
89
+ */
90
+ clear() {
91
+ this.cache.clear();
92
+ this.stats = {
93
+ hits: 0,
94
+ misses: 0,
95
+ sets: 0,
96
+ deletes: 0,
97
+ evictions: 0,
98
+ };
99
+ }
100
+ /**
101
+ * Get cache statistics
102
+ */
103
+ getStats() {
104
+ const totalRequests = this.stats.hits + this.stats.misses;
105
+ const hitRate = totalRequests > 0 ? (this.stats.hits / totalRequests) * 100 : 0;
106
+ return {
107
+ ...this.stats,
108
+ hitRate,
109
+ size: this.cache.size,
110
+ maxSize: this.config.maxSize,
111
+ };
112
+ }
113
+ /**
114
+ * Get all cache keys
115
+ */
116
+ keys() {
117
+ return Array.from(this.cache.keys());
118
+ }
119
+ /**
120
+ * Get cache size
121
+ */
122
+ size() {
123
+ return this.cache.size;
124
+ }
125
+ /**
126
+ * Check if cache is full
127
+ */
128
+ isFull() {
129
+ return this.cache.size >= this.config.maxSize;
130
+ }
131
+ /**
132
+ * Get or set a value (atomic operation)
133
+ */
134
+ getOrSet(key, factory, ttl) {
135
+ const cached = this.get(key);
136
+ if (cached !== null) {
137
+ return cached;
138
+ }
139
+ const value = factory();
140
+ this.set(key, value, ttl);
141
+ return value;
142
+ }
143
+ /**
144
+ * Get or set a value asynchronously
145
+ */
146
+ async getOrSetAsync(key, factory, ttl) {
147
+ const cached = this.get(key);
148
+ if (cached !== null) {
149
+ return cached;
150
+ }
151
+ const value = await factory();
152
+ this.set(key, value, ttl);
153
+ return value;
154
+ }
155
+ /**
156
+ * Start cleanup interval
157
+ */
158
+ startCleanup() {
159
+ if (!this.cleanupInterval) {
160
+ this.cleanupInterval = setInterval(() => {
161
+ this.cleanup();
162
+ }, this.config.cleanupInterval);
163
+ }
164
+ }
165
+ /**
166
+ * Stop cleanup interval
167
+ */
168
+ stop() {
169
+ if (this.cleanupInterval) {
170
+ clearInterval(this.cleanupInterval);
171
+ }
172
+ }
173
+ /**
174
+ * Clean up expired entries
175
+ */
176
+ cleanup() {
177
+ let cleaned = 0;
178
+ for (const [key, entry] of this.cache.entries()) {
179
+ if (this.isExpired(entry)) {
180
+ this.cache.delete(key);
181
+ cleaned++;
182
+ }
183
+ }
184
+ if (cleaned > 0) {
185
+ console.debug(`Cache cleanup: removed ${cleaned} expired entries`);
186
+ }
187
+ }
188
+ /**
189
+ * Evict least recently used entry
190
+ */
191
+ evictLRU() {
192
+ let lruKey = null;
193
+ let lruTime = Date.now();
194
+ for (const [key, entry] of this.cache.entries()) {
195
+ if (entry.lastAccessed < lruTime) {
196
+ lruTime = entry.lastAccessed;
197
+ lruKey = key;
198
+ }
199
+ }
200
+ if (lruKey) {
201
+ this.cache.delete(lruKey);
202
+ this.stats.evictions++;
203
+ }
204
+ }
205
+ /**
206
+ * Check if an entry has expired
207
+ */
208
+ isExpired(entry) {
209
+ return Date.now() > entry.timestamp + entry.ttl;
210
+ }
211
+ }
212
+ exports.Cache = Cache;
213
+ /**
214
+ * Specialized caches for different use cases
215
+ */
216
+ class VortexMathCache extends Cache {
217
+ constructor() {
218
+ super({
219
+ maxSize: 500,
220
+ defaultTTL: 600000, // 10 minutes
221
+ cleanupInterval: 300000, // 5 minutes
222
+ });
223
+ }
224
+ /**
225
+ * Cache vortex field calculations
226
+ */
227
+ getVortexField(x, y, z, strength) {
228
+ const key = `vortex_field_${x.toFixed(3)}_${y.toFixed(3)}_${z.toFixed(3)}_${strength.toFixed(3)}`;
229
+ return this.get(key);
230
+ }
231
+ setVortexField(x, y, z, strength, value) {
232
+ const key = `vortex_field_${x.toFixed(3)}_${y.toFixed(3)}_${z.toFixed(3)}_${strength.toFixed(3)}`;
233
+ this.set(key, value, 300000); // 5 minutes TTL
234
+ }
235
+ }
236
+ exports.VortexMathCache = VortexMathCache;
237
+ class ResonanceCache extends Cache {
238
+ constructor() {
239
+ super({
240
+ maxSize: 200,
241
+ defaultTTL: 300000, // 5 minutes
242
+ cleanupInterval: 300000, // 5 minutes
243
+ });
244
+ }
245
+ /**
246
+ * Cache resonance calculations
247
+ */
248
+ getResonance(level1, level2) {
249
+ const key = `resonance_${level1.toFixed(3)}_${level2.toFixed(3)}`;
250
+ return this.get(key);
251
+ }
252
+ setResonance(level1, level2, value) {
253
+ const key = `resonance_${level1.toFixed(3)}_${level2.toFixed(3)}`;
254
+ this.set(key, value, 300000); // 5 minutes TTL
255
+ }
256
+ }
257
+ exports.ResonanceCache = ResonanceCache;
258
+ /**
259
+ * Global cache instances
260
+ */
261
+ exports.globalCache = new Cache();
262
+ exports.vortexMathCache = new VortexMathCache();
263
+ exports.resonanceCache = new ResonanceCache();
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.gitIntegration = exports.GitIntegration = void 0;
4
+ const events_1 = require("events");
5
+ const child_process_1 = require("child_process");
6
+ const fs_1 = require("fs");
7
+ const util_1 = require("util");
8
+ const execAsync = (0, util_1.promisify)(child_process_1.exec);
9
+ class GitIntegration extends events_1.EventEmitter {
10
+ constructor() {
11
+ super();
12
+ this.watching = false;
13
+ this.gitDir = ".git";
14
+ // Increase max listeners to prevent memory leak warnings
15
+ this.setMaxListeners(20);
16
+ this.startWatching();
17
+ }
18
+ startWatching() {
19
+ if (this.watching)
20
+ return;
21
+ try {
22
+ this.watcher = (0, fs_1.watch)(this.gitDir, { recursive: true }, () => {
23
+ this.emitGitStatus();
24
+ this.emitRecentCommit();
25
+ });
26
+ this.watching = true;
27
+ }
28
+ catch {
29
+ console.warn("Git directory not found or not accessible");
30
+ }
31
+ }
32
+ stopWatching() {
33
+ if (this.watcher) {
34
+ this.watcher.close();
35
+ this.watching = false;
36
+ }
37
+ // Remove all listeners to prevent memory leaks
38
+ this.removeAllListeners();
39
+ }
40
+ async emitGitStatus() {
41
+ try {
42
+ const status = await this.getLiveGitStatus();
43
+ this.emit("change", { type: "status", data: status });
44
+ }
45
+ catch {
46
+ // Silently handle errors
47
+ }
48
+ }
49
+ async emitRecentCommit() {
50
+ try {
51
+ const commits = await this.getRecentCommits(1);
52
+ if (commits.length > 0) {
53
+ this.emit("change", { type: "commit", data: commits[0] });
54
+ }
55
+ }
56
+ catch {
57
+ // Silently handle errors
58
+ }
59
+ }
60
+ async getLiveGitStatus() {
61
+ try {
62
+ const { stdout } = await execAsync("git status --porcelain -b", {
63
+ cwd: process.cwd(),
64
+ });
65
+ const lines = stdout.trim().split("\n");
66
+ let branch = "main";
67
+ const staged = [];
68
+ const unstaged = [];
69
+ const untracked = [];
70
+ lines.forEach((line) => {
71
+ if (line.startsWith("## ")) {
72
+ const branchLine = line.replace("## ", "").split("...")[0];
73
+ if (branchLine) {
74
+ branch = branchLine;
75
+ }
76
+ }
77
+ else if (line.trim()) {
78
+ const status = line.substring(0, 2);
79
+ const filename = line.substring(3);
80
+ if (status.startsWith("A") || status.startsWith("M")) {
81
+ staged.push(filename);
82
+ }
83
+ else if (status.startsWith(" M") || status.startsWith(" D")) {
84
+ unstaged.push(filename);
85
+ }
86
+ else if (status.startsWith("??")) {
87
+ untracked.push(filename);
88
+ }
89
+ }
90
+ });
91
+ return { branch, staged, unstaged, untracked };
92
+ }
93
+ catch {
94
+ return { branch: "unknown", staged: [], unstaged: [], untracked: [] };
95
+ }
96
+ }
97
+ async getRecentCommits(n) {
98
+ try {
99
+ const { stdout } = await execAsync(`git log -n ${n} --pretty=format:"%H|%an|%ad|%s" --date=iso`, { cwd: process.cwd() });
100
+ if (!stdout.trim())
101
+ return [];
102
+ const commits = stdout
103
+ .trim()
104
+ .split("\n")
105
+ .map((line) => {
106
+ const [hash, author, date, ...messageParts] = line.split("|");
107
+ const message = messageParts.join("|");
108
+ return {
109
+ hash: hash || "",
110
+ author: author || "",
111
+ date: date || "",
112
+ message: message || "",
113
+ };
114
+ });
115
+ return commits.filter((commit) => commit.hash && commit.author && commit.date);
116
+ }
117
+ catch {
118
+ return [];
119
+ }
120
+ }
121
+ onGitChange(callback) {
122
+ this.on("change", callback);
123
+ }
124
+ }
125
+ exports.GitIntegration = GitIntegration;
126
+ // Export singleton instance
127
+ exports.gitIntegration = new GitIntegration();
@@ -0,0 +1,249 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.globalLogger = exports.Logger = exports.LogLevel = void 0;
4
+ const events_1 = require("events");
5
+ /**
6
+ * Production-ready logging system for ZeroPoint
7
+ *
8
+ * Provides structured logging with different levels,
9
+ * performance monitoring, and error tracking.
10
+ */
11
+ var LogLevel;
12
+ (function (LogLevel) {
13
+ LogLevel[LogLevel["ERROR"] = 0] = "ERROR";
14
+ LogLevel[LogLevel["WARN"] = 1] = "WARN";
15
+ LogLevel[LogLevel["INFO"] = 2] = "INFO";
16
+ LogLevel[LogLevel["DEBUG"] = 3] = "DEBUG";
17
+ LogLevel[LogLevel["TRACE"] = 4] = "TRACE";
18
+ })(LogLevel || (exports.LogLevel = LogLevel = {}));
19
+ class Logger extends events_1.EventEmitter {
20
+ constructor(config = {}) {
21
+ super();
22
+ this.metrics = new Map();
23
+ this.performance = new Map();
24
+ this.config = {
25
+ level: LogLevel.INFO,
26
+ enableConsole: true,
27
+ enableFile: false,
28
+ maxFileSize: 10,
29
+ maxFiles: 5,
30
+ enablePerformance: true,
31
+ enableMetrics: true,
32
+ ...config,
33
+ };
34
+ }
35
+ /**
36
+ * Log an error message
37
+ */
38
+ error(message, data, error) {
39
+ this.log(LogLevel.ERROR, message, data, error);
40
+ }
41
+ /**
42
+ * Log a warning message
43
+ */
44
+ warn(message, data) {
45
+ this.log(LogLevel.WARN, message, data);
46
+ }
47
+ /**
48
+ * Log an info message
49
+ */
50
+ info(message, data) {
51
+ this.log(LogLevel.INFO, message, data);
52
+ }
53
+ /**
54
+ * Log a debug message
55
+ */
56
+ debug(message, data) {
57
+ this.log(LogLevel.DEBUG, message, data);
58
+ }
59
+ /**
60
+ * Log a trace message
61
+ */
62
+ trace(message, data) {
63
+ this.log(LogLevel.TRACE, message, data);
64
+ }
65
+ /**
66
+ * Start performance measurement
67
+ */
68
+ startTimer(operation) {
69
+ if (!this.config.enablePerformance)
70
+ return "";
71
+ const timerId = `${operation}_${Date.now()}_${Math.random()}`;
72
+ this.performance.set(timerId, [Date.now()]);
73
+ return timerId;
74
+ }
75
+ /**
76
+ * End performance measurement
77
+ */
78
+ endTimer(timerId, operation) {
79
+ if (!this.config.enablePerformance || !timerId)
80
+ return;
81
+ const startTime = this.performance.get(timerId);
82
+ if (startTime && startTime[0] !== undefined) {
83
+ const duration = Date.now() - startTime[0];
84
+ this.performance.delete(timerId);
85
+ this.debug(`Performance: ${operation}`, { duration, operation });
86
+ // Update metrics
87
+ if (this.config.enableMetrics) {
88
+ const key = `perf_${operation}`;
89
+ const current = this.metrics.get(key) || 0;
90
+ this.metrics.set(key, current + duration);
91
+ }
92
+ }
93
+ }
94
+ /**
95
+ * Increment a metric counter
96
+ */
97
+ incrementMetric(name, value = 1) {
98
+ if (!this.config.enableMetrics)
99
+ return;
100
+ const current = this.metrics.get(name) || 0;
101
+ this.metrics.set(name, current + value);
102
+ }
103
+ /**
104
+ * Set a metric value
105
+ */
106
+ setMetric(name, value) {
107
+ if (!this.config.enableMetrics)
108
+ return;
109
+ this.metrics.set(name, value);
110
+ }
111
+ /**
112
+ * Get all metrics
113
+ */
114
+ getMetrics() {
115
+ return Object.fromEntries(this.metrics);
116
+ }
117
+ /**
118
+ * Get performance statistics
119
+ */
120
+ getPerformanceStats() {
121
+ const stats = {};
122
+ for (const [key, values] of this.performance.entries()) {
123
+ if (values.length > 1) {
124
+ // Only completed measurements
125
+ const durations = values.slice(1); // Skip start time
126
+ const avg = durations.reduce((a, b) => a + b, 0) / durations.length;
127
+ const min = Math.min(...durations);
128
+ const max = Math.max(...durations);
129
+ stats[key] = { avg, min, max, count: durations.length };
130
+ }
131
+ }
132
+ return stats;
133
+ }
134
+ /**
135
+ * Create a child logger with additional context
136
+ */
137
+ child(category, additionalData) {
138
+ const childLogger = new Logger(this.config);
139
+ if (this.config.deviceId !== undefined) {
140
+ childLogger.config.deviceId = this.config.deviceId;
141
+ }
142
+ // Override log method to add category context
143
+ const originalLog = childLogger.log.bind(childLogger);
144
+ childLogger.log = (level, message, data, error) => {
145
+ const enhancedData = {
146
+ ...additionalData,
147
+ ...data,
148
+ category,
149
+ };
150
+ originalLog(level, message, enhancedData, error);
151
+ };
152
+ return childLogger;
153
+ }
154
+ /**
155
+ * Internal logging method
156
+ */
157
+ log(level, message, data, error) {
158
+ if (level > this.config.level)
159
+ return;
160
+ const entry = {
161
+ timestamp: new Date().toISOString(),
162
+ level,
163
+ message,
164
+ deviceId: this.config.deviceId ?? "",
165
+ category: "general",
166
+ data,
167
+ };
168
+ if (error)
169
+ entry.error = error;
170
+ // Add performance data if available
171
+ if (this.config.enablePerformance) {
172
+ const memUsage = process.memoryUsage();
173
+ entry.performance = {
174
+ memory: memUsage.heapUsed / 1024 / 1024, // MB
175
+ cpu: process.cpuUsage().user / 1000000, // seconds
176
+ };
177
+ }
178
+ // Emit log event
179
+ this.emit("log", entry);
180
+ // Console output
181
+ if (this.config.enableConsole) {
182
+ this.writeToConsole(entry);
183
+ }
184
+ // File output
185
+ if (this.config.enableFile && this.config.logFilePath) {
186
+ this.writeToFile(entry);
187
+ }
188
+ }
189
+ /**
190
+ * Write log entry to console
191
+ */
192
+ writeToConsole(entry) {
193
+ const levelStr = LogLevel[entry.level];
194
+ let timestamp = "unknown";
195
+ if (entry.timestamp) {
196
+ const splitT = entry.timestamp.split("T");
197
+ if (splitT.length > 1 && splitT[1]) {
198
+ const splitDot = splitT[1].split(".");
199
+ timestamp = splitDot[0] ?? "unknown";
200
+ }
201
+ }
202
+ const prefix = `[${timestamp}] [${levelStr}]`;
203
+ let output = `${prefix} ${entry.message}`;
204
+ if (entry.deviceId) {
205
+ output += ` [Device: ${entry.deviceId}]`;
206
+ }
207
+ if (entry.data) {
208
+ output += ` | Data: ${JSON.stringify(entry.data)}`;
209
+ }
210
+ if (entry.error) {
211
+ output += ` | Error: ${entry.error.message}`;
212
+ }
213
+ // Color coding for different levels
214
+ switch (entry.level) {
215
+ case LogLevel.ERROR:
216
+ console.error("\x1b[31m%s\x1b[0m", output); // Red
217
+ break;
218
+ case LogLevel.WARN:
219
+ console.warn("\x1b[33m%s\x1b[0m", output); // Yellow
220
+ break;
221
+ case LogLevel.INFO:
222
+ console.info("\x1b[36m%s\x1b[0m", output); // Cyan
223
+ break;
224
+ default:
225
+ console.log(output);
226
+ }
227
+ }
228
+ /**
229
+ * Write log entry to file
230
+ */
231
+ writeToFile(entry) {
232
+ // This would implement file rotation and writing
233
+ // For now, just emit an event for external file handling
234
+ this.emit("fileLog", entry);
235
+ }
236
+ getLevel() {
237
+ return this.config.level;
238
+ }
239
+ }
240
+ exports.Logger = Logger;
241
+ /**
242
+ * Global logger instance
243
+ */
244
+ exports.globalLogger = new Logger({
245
+ level: LogLevel.INFO,
246
+ enableConsole: true,
247
+ enablePerformance: true,
248
+ enableMetrics: true,
249
+ });