@ultrst-armada/krnl 1.0.2 → 1.0.4

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 (237) hide show
  1. package/README.md +67 -65
  2. package/package.json +15 -8
  3. package/packages/cli/dist/bin/krnl.cjs +808 -331
  4. package/packages/cli/dist/bin/krnl.js +50 -65
  5. package/packages/cli/dist/chunk-GHWYEAPD.js +1642 -0
  6. package/packages/cli/dist/index.cjs +761 -263
  7. package/packages/cli/dist/index.d.cts +45 -2
  8. package/packages/cli/dist/index.d.ts +45 -2
  9. package/packages/cli/dist/index.js +5 -1
  10. package/packages/cli/package.json +17 -10
  11. package/packages/core/dist/index.cjs +2912 -140
  12. package/packages/core/dist/index.d.cts +614 -27
  13. package/packages/core/dist/index.d.ts +614 -27
  14. package/packages/core/dist/index.js +2903 -140
  15. package/packages/core/package.json +15 -6
  16. package/packages/create-krnl/dist/index.cjs +102 -65
  17. package/packages/create-krnl/dist/index.js +102 -65
  18. package/packages/create-krnl/package.json +5 -3
  19. package/packages/eslint-plugin/dist/index.cjs +17 -55
  20. package/packages/eslint-plugin/dist/index.d.cts +8 -43
  21. package/packages/eslint-plugin/dist/index.d.ts +8 -43
  22. package/packages/eslint-plugin/dist/index.js +17 -55
  23. package/packages/eslint-plugin/package.json +5 -4
  24. package/packages/validate/dist/index.cjs +378 -85
  25. package/packages/validate/dist/index.d.cts +11 -1
  26. package/packages/validate/dist/index.d.ts +11 -1
  27. package/packages/validate/dist/index.js +375 -82
  28. package/packages/validate/package.json +14 -7
  29. package/packages/cli/dist/K_ENT_Entity-PQ5MURQY-ZG6FZXXX.js +0 -13
  30. package/packages/cli/dist/K_LIB_Krnl_Aiko_Client-OPZAVZCW-K4CRQYA5.js +0 -8
  31. package/packages/cli/dist/K_LIB_Krnl_Ep_Tools-ROOE2TQF-LNPXZYOE.js +0 -110
  32. package/packages/cli/dist/K_LIB_Krnl_Frontend_Builder-2ZDUH6PF-3ALZPNX4.js +0 -11
  33. package/packages/cli/dist/K_LIB_Krnl_Frontend_Generator-UYNRNX2X-PJTICYSW.js +0 -11
  34. package/packages/cli/dist/K_LIB_Krnl_Registry_Client-NXV6D2QW-M5TYU55O.js +0 -8
  35. package/packages/cli/dist/K_LIB_Krnl_SubApp_Engine-7HR5HWW2-H6STOXRK.js +0 -20
  36. package/packages/cli/dist/K_LIB_Krnl_SubApp_Registry-7XYGDKJK-XPJXSF7D.js +0 -19
  37. package/packages/cli/dist/K_LIB_Krnl_SubApp_Worker_Host-CQVTGGG7-CUYGTWOW.js +0 -7
  38. package/packages/cli/dist/K_LIB_Krnl_System_App_Adapter-M6FJKLGU-VR6T4N6J.js +0 -17
  39. package/packages/cli/dist/K_LIB_Krnl_System_Base_Functionality_APIs-ZZUZ6ZG5-RLJ4QWDP.js +0 -58
  40. package/packages/cli/dist/K_LIB_Krnl_System_Magnetic_Loader-XBQO2KXF-BOQGUASC.js +0 -22
  41. package/packages/cli/dist/K_LIB_Krnl_System_Unified_Http_Adapter-RCEGP3OG-XJI7KIT5.js +0 -8
  42. package/packages/cli/dist/K_LIB_Krnl_Telemetry-77FRZ3KV-K5VCWAFW.js +0 -9
  43. package/packages/cli/dist/chunk-3TRM6CYL.js +0 -152
  44. package/packages/cli/dist/chunk-5JDK35TG.js +0 -3872
  45. package/packages/cli/dist/chunk-63PTK33I.js +0 -997
  46. package/packages/cli/dist/chunk-6NIKAMUZ.js +0 -82
  47. package/packages/cli/dist/chunk-BOXWWXQG.js +0 -400
  48. package/packages/cli/dist/chunk-EEKLK7QJ.js +0 -565
  49. package/packages/cli/dist/chunk-EG7T2IAD.js +0 -107
  50. package/packages/cli/dist/chunk-ESTKOQ7T.js +0 -1146
  51. package/packages/cli/dist/chunk-F5EHXE2O.js +0 -1036
  52. package/packages/cli/dist/chunk-F65ANSQG.js +0 -269
  53. package/packages/cli/dist/chunk-FDNCADFE.js +0 -71
  54. package/packages/cli/dist/chunk-FZ6X7PHR.js +0 -1146
  55. package/packages/cli/dist/chunk-GDLRMDAN.js +0 -127
  56. package/packages/cli/dist/chunk-HWMTCMOS.js +0 -656
  57. package/packages/cli/dist/chunk-I74QIQOD.js +0 -5536
  58. package/packages/cli/dist/chunk-JTLSTO25.js +0 -71
  59. package/packages/cli/dist/chunk-JULBBJ27.js +0 -1033
  60. package/packages/cli/dist/chunk-OHVMVRBP.js +0 -117
  61. package/packages/cli/dist/chunk-P2PCLEKX.js +0 -666
  62. package/packages/cli/dist/chunk-PJQIUOX2.js +0 -7767
  63. package/packages/cli/dist/chunk-PPOF3DJW.js +0 -471
  64. package/packages/cli/dist/chunk-Q45257P6.js +0 -173
  65. package/packages/cli/dist/chunk-QNROWGBI.js +0 -1036
  66. package/packages/cli/dist/chunk-RJNYUXZD.js +0 -977
  67. package/packages/cli/dist/chunk-SRTOPJ5W.js +0 -104
  68. package/packages/cli/dist/chunk-TCEX3MPS.js +0 -702
  69. package/packages/cli/dist/chunk-TNOAJO2J.js +0 -675
  70. package/packages/cli/dist/chunk-UR2SUCSF.js +0 -701
  71. package/packages/cli/dist/chunk-X5LOIFM7.js +0 -68
  72. package/packages/cli/dist/chunk-XIRFOO3H.js +0 -589
  73. package/packages/cli/dist/chunk-ZAAV3JXQ.js +0 -809
  74. package/packages/core/dist/K_ENT_Entity-4MB7CU4A.js +0 -12
  75. package/packages/core/dist/K_ENT_Entity-DEJGIDGH.js +0 -12
  76. package/packages/core/dist/K_ENT_Entity-FXZO5UZ2.js +0 -12
  77. package/packages/core/dist/K_ENT_Entity-HDSCXC5F.js +0 -12
  78. package/packages/core/dist/K_ENT_Entity-JILABHLW.js +0 -12
  79. package/packages/core/dist/K_ENT_Entity-PQ5MURQY.js +0 -13
  80. package/packages/core/dist/K_ENT_Entity-ROAKDIHW.js +0 -12
  81. package/packages/core/dist/K_ENT_Entity-TBVFSKDV.js +0 -12
  82. package/packages/core/dist/K_ENT_Entity-ZFLKG3JO.js +0 -12
  83. package/packages/core/dist/K_LIB_Krnl_Aiko_Client-OPZAVZCW.js +0 -8
  84. package/packages/core/dist/K_LIB_Krnl_Ep_Tools-ROOE2TQF.js +0 -110
  85. package/packages/core/dist/K_LIB_Krnl_Frontend_Builder-2ZDUH6PF.js +0 -9
  86. package/packages/core/dist/K_LIB_Krnl_Frontend_Generator-UYNRNX2X.js +0 -9
  87. package/packages/core/dist/K_LIB_Krnl_Registry_Client-NXV6D2QW.js +0 -8
  88. package/packages/core/dist/K_LIB_Krnl_SubApp_Engine-7HR5HWW2.js +0 -20
  89. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-4C6GBQAG.js +0 -18
  90. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-6V23A6F6.js +0 -18
  91. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-7XYGDKJK.js +0 -19
  92. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-DYLLC5G2.js +0 -18
  93. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-F4FOFAUP.js +0 -18
  94. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-FBOXXMI3.js +0 -18
  95. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-Q73BWLNP.js +0 -18
  96. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-QM2C4MVA.js +0 -18
  97. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-QUGI6SMP.js +0 -18
  98. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-RGMTBHNP.js +0 -18
  99. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-RWR7UNDW.js +0 -18
  100. package/packages/core/dist/K_LIB_Krnl_SubApp_Worker_Host-CQVTGGG7.js +0 -7
  101. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-32MFJJ5Z.js +0 -17
  102. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-4J4CEWRY.js +0 -17
  103. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-A366YHF2.js +0 -17
  104. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-LK4LYJHI.js +0 -17
  105. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-M6FJKLGU.js +0 -17
  106. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-NW3K63II.js +0 -17
  107. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-QDHTI5ZV.js +0 -17
  108. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-VHCT6VIW.js +0 -17
  109. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-WBRKF24R.js +0 -17
  110. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-XKYQYT6Q.js +0 -17
  111. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-Z2PWZYDZ.js +0 -17
  112. package/packages/core/dist/K_LIB_Krnl_System_Base_Functionality_APIs-ZZUZ6ZG5.js +0 -58
  113. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-2EZU7QF4.js +0 -21
  114. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-6G3AQNAV.js +0 -21
  115. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-B2NZMQUG.js +0 -21
  116. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-C2RABMZP.js +0 -21
  117. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-HHE3NZ4F.js +0 -21
  118. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-LHFGR6WK.js +0 -21
  119. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-M74BLM3N.js +0 -21
  120. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-PT6ZA6EA.js +0 -21
  121. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-SP52V3CX.js +0 -21
  122. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-XBQO2KXF.js +0 -22
  123. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-YNSEUHJJ.js +0 -21
  124. package/packages/core/dist/K_LIB_Krnl_System_Unified_Http_Adapter-M6SBHIVA.js +0 -8
  125. package/packages/core/dist/K_LIB_Krnl_System_Unified_Http_Adapter-RCEGP3OG.js +0 -8
  126. package/packages/core/dist/K_LIB_Krnl_Telemetry-77FRZ3KV.js +0 -9
  127. package/packages/core/dist/chunk-33L2J7V7.js +0 -82
  128. package/packages/core/dist/chunk-3ES4K2ZP.js +0 -817
  129. package/packages/core/dist/chunk-3SMHVVLL.js +0 -82
  130. package/packages/core/dist/chunk-3UEZ7JQA.js +0 -4877
  131. package/packages/core/dist/chunk-3XIE6KBD.js +0 -4877
  132. package/packages/core/dist/chunk-46ZLCML6.js +0 -107
  133. package/packages/core/dist/chunk-4UEL3DWJ.js +0 -107
  134. package/packages/core/dist/chunk-54GWZ5PC.js +0 -82
  135. package/packages/core/dist/chunk-6QCYRS5L.js +0 -127
  136. package/packages/core/dist/chunk-6ULMHNXR.js +0 -104
  137. package/packages/core/dist/chunk-7WUETJEV.js +0 -117
  138. package/packages/core/dist/chunk-A5KRAYDB.js +0 -107
  139. package/packages/core/dist/chunk-ANEAZ3PO.js +0 -107
  140. package/packages/core/dist/chunk-BE76RL6F.js +0 -82
  141. package/packages/core/dist/chunk-CIARVYDO.js +0 -107
  142. package/packages/core/dist/chunk-CR2ANE62.js +0 -107
  143. package/packages/core/dist/chunk-DI27MOR7.js +0 -173
  144. package/packages/core/dist/chunk-E6RLFHM5.js +0 -596
  145. package/packages/core/dist/chunk-EELAPMNV.js +0 -4877
  146. package/packages/core/dist/chunk-ENZ2RQVJ.js +0 -107
  147. package/packages/core/dist/chunk-F2U6CX4F.js +0 -4877
  148. package/packages/core/dist/chunk-FKG64OHL.js +0 -82
  149. package/packages/core/dist/chunk-FYAZJYM5.js +0 -772
  150. package/packages/core/dist/chunk-G4NP4RDQ.js +0 -82
  151. package/packages/core/dist/chunk-GADIRLRS.js +0 -473
  152. package/packages/core/dist/chunk-GR6CSLQJ.js +0 -772
  153. package/packages/core/dist/chunk-HDS7AT6O.js +0 -772
  154. package/packages/core/dist/chunk-HIMEZUU2.js +0 -71
  155. package/packages/core/dist/chunk-IB4UHG5I.js +0 -596
  156. package/packages/core/dist/chunk-J7ZYNVRS.js +0 -772
  157. package/packages/core/dist/chunk-JVLZU4K7.js +0 -604
  158. package/packages/core/dist/chunk-JYXXI7Q3.js +0 -82
  159. package/packages/core/dist/chunk-K54K2KZW.js +0 -192
  160. package/packages/core/dist/chunk-K6VHLBNH.js +0 -3316
  161. package/packages/core/dist/chunk-KCBP7ZYA.js +0 -596
  162. package/packages/core/dist/chunk-KFQGP6VL.js +0 -33
  163. package/packages/core/dist/chunk-KIUEUI7K.js +0 -82
  164. package/packages/core/dist/chunk-LB67NIZP.js +0 -949
  165. package/packages/core/dist/chunk-LDTYFUNW.js +0 -596
  166. package/packages/core/dist/chunk-MLVWARD4.js +0 -596
  167. package/packages/core/dist/chunk-MPYVXHKO.js +0 -2777
  168. package/packages/core/dist/chunk-MRQ3MITU.js +0 -772
  169. package/packages/core/dist/chunk-MVUN7I7O.js +0 -107
  170. package/packages/core/dist/chunk-NDDOIRW7.js +0 -596
  171. package/packages/core/dist/chunk-O3KDB5MH.js +0 -3330
  172. package/packages/core/dist/chunk-OEINUDSE.js +0 -400
  173. package/packages/core/dist/chunk-OPDENPT4.js +0 -4877
  174. package/packages/core/dist/chunk-P6XEM2LA.js +0 -429
  175. package/packages/core/dist/chunk-QKMRSQV4.js +0 -82
  176. package/packages/core/dist/chunk-R6CCWALL.js +0 -4877
  177. package/packages/core/dist/chunk-RAMMOO73.js +0 -774
  178. package/packages/core/dist/chunk-S3FTZFG6.js +0 -772
  179. package/packages/core/dist/chunk-T2ZVN434.js +0 -4877
  180. package/packages/core/dist/chunk-TFHLDMIA.js +0 -107
  181. package/packages/core/dist/chunk-TI3QUCIJ.js +0 -107
  182. package/packages/core/dist/chunk-TR2BAIGI.js +0 -107
  183. package/packages/core/dist/chunk-UGVVJKC6.js +0 -4877
  184. package/packages/core/dist/chunk-V2DX7YIU.js +0 -984
  185. package/packages/core/dist/chunk-W4IHYUYD.js +0 -772
  186. package/packages/core/dist/chunk-W6WBG5OY.js +0 -4877
  187. package/packages/core/dist/chunk-WN3M7O7H.js +0 -3312
  188. package/packages/core/dist/chunk-WR3NCU7U.js +0 -4877
  189. package/packages/core/dist/chunk-XC6B6L27.js +0 -82
  190. package/packages/core/dist/chunk-XNSE64ZY.js +0 -3316
  191. package/packages/core/dist/chunk-XROES2WN.js +0 -634
  192. package/packages/core/dist/chunk-XSCKNRCZ.js +0 -5020
  193. package/packages/core/dist/chunk-XVABPAUZ.js +0 -82
  194. package/packages/core/dist/chunk-YOBCB5C5.js +0 -596
  195. package/packages/core/dist/chunk-YUK6Q563.js +0 -666
  196. package/packages/core/dist/chunk-YXGL3ZEU.js +0 -1030
  197. package/packages/core/dist/chunk-ZINJ5OUX.js +0 -596
  198. package/packages/core/dist/chunk-ZPFD4BIQ.js +0 -604
  199. package/packages/core/dist/chunk-ZQZBFG6F.js +0 -4826
  200. package/packages/core/dist/chunk-ZZFRJGXM.js +0 -4877
  201. package/packages/create-krnl/dist/K_ENT_Entity-PQ5MURQY-R2OH4VXE.js +0 -14
  202. package/packages/create-krnl/dist/K_LIB_Krnl_Aiko_Client-OPZAVZCW-AZM5HF4M.js +0 -9
  203. package/packages/create-krnl/dist/K_LIB_Krnl_Ep_Tools-ROOE2TQF-X5N6SV2S.js +0 -111
  204. package/packages/create-krnl/dist/K_LIB_Krnl_Frontend_Builder-2ZDUH6PF-5PFHF4JU.js +0 -12
  205. package/packages/create-krnl/dist/K_LIB_Krnl_Frontend_Generator-UYNRNX2X-ED33OQPH.js +0 -12
  206. package/packages/create-krnl/dist/K_LIB_Krnl_Registry_Client-NXV6D2QW-YGQLVR4P.js +0 -9
  207. package/packages/create-krnl/dist/K_LIB_Krnl_SubApp_Engine-7HR5HWW2-VM7CTU2L.js +0 -21
  208. package/packages/create-krnl/dist/K_LIB_Krnl_SubApp_Registry-7XYGDKJK-Y2GQFJ7I.js +0 -21
  209. package/packages/create-krnl/dist/K_LIB_Krnl_SubApp_Worker_Host-CQVTGGG7-L3JQWO54.js +0 -8
  210. package/packages/create-krnl/dist/K_LIB_Krnl_System_App_Adapter-M6FJKLGU-KQARASPR.js +0 -19
  211. package/packages/create-krnl/dist/K_LIB_Krnl_System_Base_Functionality_APIs-ZZUZ6ZG5-OF3IGLVL.js +0 -59
  212. package/packages/create-krnl/dist/K_LIB_Krnl_System_Magnetic_Loader-XBQO2KXF-JOLHKOEX.js +0 -24
  213. package/packages/create-krnl/dist/K_LIB_Krnl_System_Unified_Http_Adapter-RCEGP3OG-L46LSHKQ.js +0 -10
  214. package/packages/create-krnl/dist/K_LIB_Krnl_Telemetry-77FRZ3KV-4JUPRR3X.js +0 -10
  215. package/packages/create-krnl/dist/chunk-3TRM6CYL.js +0 -152
  216. package/packages/create-krnl/dist/chunk-3URCB3QS.js +0 -127
  217. package/packages/create-krnl/dist/chunk-5JDK35TG.js +0 -3872
  218. package/packages/create-krnl/dist/chunk-A2XAXDOW.js +0 -812
  219. package/packages/create-krnl/dist/chunk-AN6TMQHG.js +0 -1033
  220. package/packages/create-krnl/dist/chunk-BOXWWXQG.js +0 -400
  221. package/packages/create-krnl/dist/chunk-BPTBREBG.js +0 -38
  222. package/packages/create-krnl/dist/chunk-FDNCADFE.js +0 -71
  223. package/packages/create-krnl/dist/chunk-JTLSTO25.js +0 -71
  224. package/packages/create-krnl/dist/chunk-M3NCUIPL.js +0 -107
  225. package/packages/create-krnl/dist/chunk-N2EONSOC.js +0 -7769
  226. package/packages/create-krnl/dist/chunk-OHVMVRBP.js +0 -117
  227. package/packages/create-krnl/dist/chunk-Q45257P6.js +0 -173
  228. package/packages/create-krnl/dist/chunk-QGM4M3NI.js +0 -37
  229. package/packages/create-krnl/dist/chunk-RJNYUXZD.js +0 -977
  230. package/packages/create-krnl/dist/chunk-SRTOPJ5W.js +0 -104
  231. package/packages/create-krnl/dist/chunk-UPBIGEC3.js +0 -666
  232. package/packages/create-krnl/dist/chunk-V2DB7UD7.js +0 -82
  233. package/packages/create-krnl/dist/chunk-WMHLIUI6.js +0 -3644
  234. package/packages/create-krnl/dist/chunk-XIRFOO3H.js +0 -589
  235. package/packages/create-krnl/dist/chunk-Y2CEEVZP.js +0 -5536
  236. package/packages/create-krnl/dist/main-DXUMPBND.js +0 -2217
  237. package/packages/create-krnl/dist/wrapper-SDF2VKX3.js +0 -31
@@ -1,596 +0,0 @@
1
- // src/tools/ObjectKit.js
2
- var ObjectKit = class _ObjectKit {
3
- /**
4
- * Structurally deep clones an object with circular dependency check.
5
- */
6
- static deepClone(obj, seen = /* @__PURE__ */ new Map()) {
7
- if (obj === null || typeof obj !== "object") {
8
- return obj;
9
- }
10
- if (seen.has(obj)) {
11
- return seen.get(obj);
12
- }
13
- if (obj instanceof Date) {
14
- return new Date(obj.getTime());
15
- }
16
- if (obj instanceof RegExp) {
17
- return new RegExp(obj.source, obj.flags);
18
- }
19
- if (Array.isArray(obj)) {
20
- const cloneArr = [];
21
- seen.set(obj, cloneArr);
22
- for (const item of obj) {
23
- cloneArr.push(_ObjectKit.deepClone(item, seen));
24
- }
25
- return cloneArr;
26
- }
27
- const cloneObj = Object.create(Object.getPrototypeOf(obj));
28
- seen.set(obj, cloneObj);
29
- for (const key of Reflect.ownKeys(obj)) {
30
- const descriptor = Reflect.getOwnPropertyDescriptor(obj, key);
31
- if (descriptor) {
32
- descriptor.value = _ObjectKit.deepClone(descriptor.value, seen);
33
- Object.defineProperty(cloneObj, key, descriptor);
34
- }
35
- }
36
- return cloneObj;
37
- }
38
- /**
39
- * Recursively deep merges override objects into a base.
40
- */
41
- static deepMerge(base, ...overrides) {
42
- let result = _ObjectKit.deepClone(base);
43
- for (const override of overrides) {
44
- if (override === null || typeof override !== "object") {
45
- continue;
46
- }
47
- for (const key of Object.keys(override)) {
48
- const val = override[key];
49
- if (val === void 0) {
50
- delete result[key];
51
- } else if (val && typeof val === "object" && !Array.isArray(val)) {
52
- if (result[key] && typeof result[key] === "object" && !Array.isArray(result[key])) {
53
- result[key] = _ObjectKit.deepMerge(result[key], val);
54
- } else {
55
- result[key] = _ObjectKit.deepClone(val);
56
- }
57
- } else {
58
- result[key] = _ObjectKit.deepClone(val);
59
- }
60
- }
61
- }
62
- return result;
63
- }
64
- /**
65
- * Performs a strict structural equality check.
66
- */
67
- static deepEqual(a, b) {
68
- if (Object.is(a, b))
69
- return true;
70
- if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) {
71
- return false;
72
- }
73
- if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) {
74
- return false;
75
- }
76
- if (a instanceof Date && b instanceof Date) {
77
- return a.getTime() === b.getTime();
78
- }
79
- if (a instanceof RegExp && b instanceof RegExp) {
80
- return a.toString() === b.toString();
81
- }
82
- const keysA = Reflect.ownKeys(a);
83
- const keysB = Reflect.ownKeys(b);
84
- if (keysA.length !== keysB.length)
85
- return false;
86
- const setB = new Set(keysB);
87
- for (const key of keysA) {
88
- if (!setB.has(key))
89
- return false;
90
- if (!_ObjectKit.deepEqual(a[key], b[key]))
91
- return false;
92
- }
93
- return true;
94
- }
95
- /**
96
- * Performs an object diff between before and after states.
97
- */
98
- static objectDiff(before, after) {
99
- const added = {};
100
- const removed = {};
101
- const changed = {};
102
- if (before === null || typeof before !== "object" || after === null || typeof after !== "object") {
103
- return { added, removed, changed };
104
- }
105
- const keysBefore = Object.keys(before);
106
- const keysAfter = Object.keys(after);
107
- for (const key of keysAfter) {
108
- if (!(key in before)) {
109
- added[key] = _ObjectKit.deepClone(after[key]);
110
- } else if (!_ObjectKit.deepEqual(before[key], after[key])) {
111
- if (before[key] && typeof before[key] === "object" && after[key] && typeof after[key] === "object" && !Array.isArray(before[key]) && !Array.isArray(after[key])) {
112
- const nested = _ObjectKit.objectDiff(before[key], after[key]);
113
- if (Object.keys(nested.added).length > 0 || Object.keys(nested.removed).length > 0 || Object.keys(nested.changed).length > 0) {
114
- changed[key] = nested;
115
- }
116
- } else {
117
- changed[key] = { from: _ObjectKit.deepClone(before[key]), to: _ObjectKit.deepClone(after[key]) };
118
- }
119
- }
120
- }
121
- for (const key of keysBefore) {
122
- if (!(key in after)) {
123
- removed[key] = _ObjectKit.deepClone(before[key]);
124
- }
125
- }
126
- return { added, removed, changed };
127
- }
128
- /**
129
- * Accesses an in-memory object by dot-notation.
130
- */
131
- static getPath(obj, path2, defaultValue) {
132
- if (!path2)
133
- return obj;
134
- const parts = path2.split(".");
135
- let current = obj;
136
- for (const part of parts) {
137
- if (current === null || current === void 0) {
138
- return defaultValue;
139
- }
140
- current = current[part];
141
- }
142
- return current !== void 0 ? current : defaultValue;
143
- }
144
- /**
145
- * Mutates or sets an in-memory object by dot-notation.
146
- */
147
- static setPath(obj, path2, value) {
148
- if (!path2)
149
- return obj;
150
- const parts = path2.split(".");
151
- let current = obj;
152
- for (let i = 0; i < parts.length - 1; i++) {
153
- const part = parts[i];
154
- if (current[part] === void 0 || current[part] === null) {
155
- current[part] = {};
156
- }
157
- current = current[part];
158
- }
159
- current[parts[parts.length - 1]] = value;
160
- return obj;
161
- }
162
- };
163
-
164
- // src/tools/KrnlFS.js
165
- import fs from "fs";
166
- import fsp from "fs/promises";
167
- import path from "path";
168
- import os from "os";
169
- var FileLock = class _FileLock {
170
- static locks = /* @__PURE__ */ new Map();
171
- static async acquire(filePath) {
172
- const resolvedPath = path.resolve(filePath);
173
- const existing = _FileLock.locks.get(resolvedPath) || Promise.resolve();
174
- let release = () => {
175
- };
176
- const nextLock = new Promise((resolve) => {
177
- release = () => {
178
- _FileLock.locks.delete(resolvedPath);
179
- resolve();
180
- };
181
- });
182
- _FileLock.locks.set(resolvedPath, nextLock);
183
- await existing;
184
- return release;
185
- }
186
- };
187
- var KrnlFS = class _KrnlFS {
188
- // --- File primitives ---
189
- static async readFile(filePath, encoding = "utf8") {
190
- return await fsp.readFile(filePath, encoding);
191
- }
192
- static async writeFile(filePath, content) {
193
- await fsp.writeFile(filePath, content);
194
- }
195
- /**
196
- * Atomic file writing via temp files.
197
- */
198
- static async writeFileAtomic(filePath, content) {
199
- const dir = path.dirname(filePath);
200
- await _KrnlFS.ensureDir(dir);
201
- const tempFile = path.join(dir, `.${path.basename(filePath)}.tmp_${Date.now()}_${Math.random().toString(36).substring(7)}`);
202
- try {
203
- await fsp.writeFile(tempFile, content);
204
- await fsp.rename(tempFile, filePath);
205
- } catch (e) {
206
- if (fs.existsSync(tempFile)) {
207
- await fsp.unlink(tempFile).catch(() => {
208
- });
209
- }
210
- throw e;
211
- }
212
- }
213
- static async appendFile(filePath, content) {
214
- await fsp.appendFile(filePath, content);
215
- }
216
- static async deleteFile(filePath) {
217
- await fsp.unlink(filePath);
218
- }
219
- static async fileExists(filePath) {
220
- try {
221
- const stat = await fsp.stat(filePath);
222
- return stat.isFile();
223
- } catch (e) {
224
- return false;
225
- }
226
- }
227
- static async getFileStat(filePath) {
228
- const stat = await fsp.stat(filePath);
229
- return {
230
- size: stat.size,
231
- createdAt: stat.birthtime,
232
- modifiedAt: stat.mtime,
233
- isDir: stat.isDirectory()
234
- };
235
- }
236
- // --- JSON convenience ---
237
- static async readJSON(filePath) {
238
- try {
239
- const content = await _KrnlFS.readFile(filePath, "utf8");
240
- return JSON.parse(content);
241
- } catch (e) {
242
- return null;
243
- }
244
- }
245
- static async writeJSON(filePath, data, indent = 2) {
246
- const content = JSON.stringify(data, null, indent);
247
- await _KrnlFS.writeFileAtomic(filePath, content);
248
- }
249
- static async updateJSON(filePath, patch) {
250
- const release = await FileLock.acquire(filePath);
251
- try {
252
- let existing = await _KrnlFS.readJSON(filePath);
253
- if (!existing) {
254
- existing = {};
255
- }
256
- const updated = ObjectKit.deepMerge(existing, patch);
257
- await _KrnlFS.writeJSON(filePath, updated);
258
- return updated;
259
- } finally {
260
- release();
261
- }
262
- }
263
- // --- Directory primitives ---
264
- static async ensureDir(dirPath) {
265
- await fsp.mkdir(dirPath, { recursive: true });
266
- }
267
- static async deleteDir(dirPath, recursive = true) {
268
- await fsp.rm(dirPath, { recursive, force: true });
269
- }
270
- static async listDir(dirPath) {
271
- return await fsp.readdir(dirPath);
272
- }
273
- static async *walkDir(dirPath, filter) {
274
- const list = await _KrnlFS.listDir(dirPath);
275
- for (const item of list) {
276
- const full = path.join(dirPath, item);
277
- const stat = await _KrnlFS.getFileStat(full);
278
- if (stat.isDir) {
279
- yield* _KrnlFS.walkDir(full, filter);
280
- } else {
281
- if (!filter || filter(full)) {
282
- yield full;
283
- }
284
- }
285
- }
286
- }
287
- static async dirExists(dirPath) {
288
- try {
289
- const stat = await fsp.stat(dirPath);
290
- return stat.isDirectory();
291
- } catch (e) {
292
- return false;
293
- }
294
- }
295
- static async copyDir(src, dest) {
296
- await _KrnlFS.ensureDir(dest);
297
- const list = await _KrnlFS.listDir(src);
298
- for (const item of list) {
299
- const srcItem = path.join(src, item);
300
- const destItem = path.join(dest, item);
301
- const stat = await _KrnlFS.getFileStat(srcItem);
302
- if (stat.isDir) {
303
- await _KrnlFS.copyDir(srcItem, destItem);
304
- } else {
305
- await fsp.copyFile(srcItem, destItem);
306
- }
307
- }
308
- }
309
- // --- Path utilities ---
310
- static join(...parts) {
311
- return path.join(...parts);
312
- }
313
- static resolve(...parts) {
314
- return path.resolve(...parts);
315
- }
316
- static relative(from, to) {
317
- return path.relative(from, to);
318
- }
319
- static basename(filePath, ext) {
320
- return path.basename(filePath, ext);
321
- }
322
- static dirname(filePath) {
323
- return path.dirname(filePath);
324
- }
325
- static extname(filePath) {
326
- return path.extname(filePath);
327
- }
328
- static normalize(filePath) {
329
- return path.normalize(filePath);
330
- }
331
- static isSafe(filePath, root) {
332
- const resolvedPath = path.resolve(filePath);
333
- const resolvedRoot = path.resolve(root);
334
- return resolvedPath.startsWith(resolvedRoot);
335
- }
336
- // --- Candidate resolution ---
337
- static async firstExisting(candidates) {
338
- for (const cand of candidates) {
339
- if (await _KrnlFS.fileExists(cand)) {
340
- return cand;
341
- }
342
- }
343
- return null;
344
- }
345
- // --- Watching ---
346
- static watchFile(filePath, handler, debounceMs = 100) {
347
- let timer = null;
348
- return fs.watch(filePath, (event) => {
349
- if (timer)
350
- clearTimeout(timer);
351
- timer = setTimeout(() => handler(event), debounceMs);
352
- });
353
- }
354
- static watchDir(dirPath, handler, debounceMs = 100) {
355
- let timer = null;
356
- return fs.watch(dirPath, (event, filename) => {
357
- if (timer)
358
- clearTimeout(timer);
359
- timer = setTimeout(() => handler(event, filename), debounceMs);
360
- });
361
- }
362
- // --- Temp ---
363
- static createTempFile(prefix = "tmp-") {
364
- return path.join(os.tmpdir(), `${prefix}${Math.random().toString(36).substring(7)}.tmp`);
365
- }
366
- static createTempDir(prefix = "tmp-dir-") {
367
- const dir = path.join(os.tmpdir(), `${prefix}${Math.random().toString(36).substring(7)}`);
368
- fs.mkdirSync(dir, { recursive: true });
369
- return dir;
370
- }
371
- static async withTempDir(fn, prefix = "tmp-") {
372
- const tempDir = _KrnlFS.createTempDir(prefix);
373
- try {
374
- return await fn(tempDir);
375
- } finally {
376
- await _KrnlFS.deleteDir(tempDir, true).catch(() => {
377
- });
378
- }
379
- }
380
- };
381
-
382
- // src/tools/AsyncKit.js
383
- var AsyncKit = class _AsyncKit {
384
- /**
385
- * Classic sleep/delay.
386
- */
387
- static sleep(ms) {
388
- return new Promise((resolve) => setTimeout(resolve, ms));
389
- }
390
- /**
391
- * Rejects if the task does not finish within ms.
392
- */
393
- static withTimeout(promise, ms, label = "Operation") {
394
- let timer;
395
- const timeoutPromise = new Promise((_, reject) => {
396
- timer = setTimeout(() => {
397
- reject(new Error(`[KrnlTimeoutError] ${label} timed out after ${ms}ms`));
398
- }, ms);
399
- });
400
- return Promise.race([
401
- promise.then((val) => {
402
- clearTimeout(timer);
403
- return val;
404
- }),
405
- timeoutPromise
406
- ]);
407
- }
408
- /**
409
- * Retries an async execution up to maxAttempts times.
410
- */
411
- static async retry(fn, maxAttempts, delayMs = 1e3) {
412
- let attempts = 0;
413
- while (attempts < maxAttempts) {
414
- try {
415
- return await fn();
416
- } catch (err) {
417
- attempts++;
418
- if (attempts >= maxAttempts) {
419
- throw err;
420
- }
421
- await _AsyncKit.sleep(delayMs);
422
- }
423
- }
424
- throw new Error("Retry failed");
425
- }
426
- static async pLimit(tasks, concurrency) {
427
- const results = [];
428
- let index = 0;
429
- const worker = async () => {
430
- while (index < tasks.length) {
431
- const i = index++;
432
- results[i] = await tasks[i]();
433
- }
434
- };
435
- const workers = [];
436
- for (let i = 0; i < concurrency && i < tasks.length; i++) {
437
- workers.push(worker());
438
- }
439
- await Promise.all(workers);
440
- return results;
441
- }
442
- /**
443
- * Debounces a function.
444
- */
445
- static debounce(fn, ms) {
446
- let timer = null;
447
- return (...args) => {
448
- if (timer)
449
- clearTimeout(timer);
450
- timer = setTimeout(() => fn(...args), ms);
451
- };
452
- }
453
- /**
454
- * Throttles a function.
455
- */
456
- static throttle(fn, ms) {
457
- let lastCall = 0;
458
- return (...args) => {
459
- const now = Date.now();
460
- if (now - lastCall >= ms) {
461
- lastCall = now;
462
- fn(...args);
463
- }
464
- };
465
- }
466
- /**
467
- * Wraps a function to run only once and cache its outcome.
468
- */
469
- static once(fn) {
470
- let run = false;
471
- let result;
472
- return (...args) => {
473
- if (!run) {
474
- run = true;
475
- result = fn(...args);
476
- }
477
- return result;
478
- };
479
- }
480
- /**
481
- * computational memoization cache helper.
482
- */
483
- static memoize(fn, keyFn) {
484
- const cache = /* @__PURE__ */ new Map();
485
- return (...args) => {
486
- const key = keyFn ? keyFn(...args) : JSON.stringify(args);
487
- if (cache.has(key)) {
488
- return cache.get(key);
489
- }
490
- const val = fn(...args);
491
- cache.set(key, val);
492
- return val;
493
- };
494
- }
495
- };
496
-
497
- // src/tools/KrnlHTTP.js
498
- var KrnlHTTP = class _KrnlHTTP {
499
- /**
500
- * Helper to perform fetch with timeout and retries.
501
- */
502
- static async requestRaw(url, opts = {}) {
503
- const timeout = opts.timeout || 6e4;
504
- const retries = opts.retries || 0;
505
- const perform = async () => {
506
- const controller = new AbortController();
507
- const id = setTimeout(() => controller.abort(), timeout);
508
- try {
509
- const response = await fetch(url, {
510
- ...opts,
511
- signal: controller.signal
512
- });
513
- clearTimeout(id);
514
- return response;
515
- } catch (e) {
516
- clearTimeout(id);
517
- throw e;
518
- }
519
- };
520
- return await AsyncKit.retry(perform, retries + 1, 1e3);
521
- }
522
- static async request(url, opts = {}) {
523
- try {
524
- const res = await _KrnlHTTP.requestRaw(url, opts);
525
- if (!res.ok) {
526
- return { status: "error", message: `HTTP Error ${res.status}: ${res.statusText}`, code: res.status };
527
- }
528
- const data = await res.json();
529
- return { status: "success", data };
530
- } catch (e) {
531
- return { status: "error", message: e.message || String(e) };
532
- }
533
- }
534
- static async get(url, opts = {}) {
535
- return await _KrnlHTTP.request(url, { ...opts, method: "GET" });
536
- }
537
- static async post(url, body, opts = {}) {
538
- return await _KrnlHTTP.request(url, {
539
- ...opts,
540
- method: "POST",
541
- headers: { "Content-Type": "application/json", ...opts.headers },
542
- body: JSON.stringify(body)
543
- });
544
- }
545
- static async put(url, body, opts = {}) {
546
- return await _KrnlHTTP.request(url, {
547
- ...opts,
548
- method: "PUT",
549
- headers: { "Content-Type": "application/json", ...opts.headers },
550
- body: JSON.stringify(body)
551
- });
552
- }
553
- static async del(url, opts = {}) {
554
- return await _KrnlHTTP.request(url, { ...opts, method: "DELETE" });
555
- }
556
- /**
557
- * Creates a client instance.
558
- */
559
- static createClient(baseUrl, defaultHeaders = {}) {
560
- return {
561
- get: (path2, opts = {}) => _KrnlHTTP.get(`${baseUrl}${path2}`, { ...opts, headers: { ...defaultHeaders, ...opts.headers } }),
562
- post: (path2, body, opts = {}) => _KrnlHTTP.post(`${baseUrl}${path2}`, body, { ...opts, headers: { ...defaultHeaders, ...opts.headers } }),
563
- put: (path2, body, opts = {}) => _KrnlHTTP.put(`${baseUrl}${path2}`, body, { ...opts, headers: { ...defaultHeaders, ...opts.headers } }),
564
- del: (path2, opts = {}) => _KrnlHTTP.del(`${baseUrl}${path2}`, { ...opts, headers: { ...defaultHeaders, ...opts.headers } })
565
- };
566
- }
567
- /**
568
- * Streaming SSE / Chunk response.
569
- */
570
- static async *streamResponse(url, opts = {}) {
571
- const res = await _KrnlHTTP.requestRaw(url, opts);
572
- if (!res.ok || !res.body) {
573
- throw new Error(`Failed to initialize stream: HTTP ${res.status}`);
574
- }
575
- const reader = res.body.getReader();
576
- const decoder = new TextDecoder();
577
- try {
578
- while (true) {
579
- const { done, value } = await reader.read();
580
- if (done)
581
- break;
582
- yield decoder.decode(value, { stream: true });
583
- }
584
- } finally {
585
- reader.releaseLock();
586
- }
587
- }
588
- };
589
-
590
- export {
591
- ObjectKit,
592
- FileLock,
593
- KrnlFS,
594
- AsyncKit,
595
- KrnlHTTP
596
- };