@prestizni-software/server-dem 0.7.4 → 0.9.0

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 (517) hide show
  1. package/AutoUpdateClientManagerClass.d.ts +158 -0
  2. package/AutoUpdateClientManagerClass.js +820 -0
  3. package/AutoUpdateClientManagerClass.js.map +1 -0
  4. package/AutoUpdateManagerClass.d.ts +102 -0
  5. package/AutoUpdateManagerClass.js +117 -0
  6. package/AutoUpdateManagerClass.js.map +1 -0
  7. package/AutoUpdateServerManagerClass.d.ts +238 -0
  8. package/AutoUpdateServerManagerClass.js +1087 -0
  9. package/AutoUpdateServerManagerClass.js.map +1 -0
  10. package/AutoUpdatedClientObjectClass.d.ts +244 -0
  11. package/AutoUpdatedClientObjectClass.js +969 -0
  12. package/AutoUpdatedClientObjectClass.js.map +1 -0
  13. package/AutoUpdatedServerObjectClass.d.ts +134 -0
  14. package/AutoUpdatedServerObjectClass.js +346 -0
  15. package/AutoUpdatedServerObjectClass.js.map +1 -0
  16. package/ClientTypes.d.ts +15 -0
  17. package/ClientTypes.js +52 -0
  18. package/ClientTypes.js.map +1 -0
  19. package/CommonTypes.d.ts +296 -0
  20. package/CommonTypes.js +233 -0
  21. package/CommonTypes.js.map +1 -0
  22. package/CommonTypes_server.d.ts +1 -0
  23. package/CommonTypes_server.js +2 -0
  24. package/CommonTypes_server.js.map +1 -0
  25. package/{dist/DEMErrors.js.map → DEMErrors.js.map} +1 -1
  26. package/ServerTypes.d.ts +16 -0
  27. package/ServerTypes.js +60 -0
  28. package/ServerTypes.js.map +1 -0
  29. package/client.d.ts +6 -0
  30. package/client.js +7 -0
  31. package/client.js.map +1 -0
  32. package/coverage/lcov-report/block-navigation.js +71 -0
  33. package/coverage/lcov-report/block-navigation.js.map +1 -0
  34. package/coverage/lcov-report/prettify.js +478 -0
  35. package/coverage/lcov-report/prettify.js.map +1 -0
  36. package/coverage/lcov-report/sorter.js +177 -0
  37. package/coverage/lcov-report/sorter.js.map +1 -0
  38. package/dist/AutoUpdateClientManagerClass.d.ts +20 -0
  39. package/dist/AutoUpdateClientManagerClass.js +283 -0
  40. package/dist/AutoUpdateClientManagerClass.js.map +1 -0
  41. package/dist/AutoUpdateManagerClass.d.ts +17 -96
  42. package/dist/AutoUpdateManagerClass.js +15 -73
  43. package/dist/AutoUpdateManagerClass.js.map +1 -1
  44. package/dist/AutoUpdateServerManagerClass.d.ts +18 -207
  45. package/dist/AutoUpdateServerManagerClass.js +198 -680
  46. package/dist/AutoUpdateServerManagerClass.js.map +1 -1
  47. package/dist/AutoUpdatedClientObjectClass.d.ts +63 -206
  48. package/dist/AutoUpdatedClientObjectClass.js +660 -707
  49. package/dist/AutoUpdatedClientObjectClass.js.map +1 -1
  50. package/dist/AutoUpdatedServerObjectClass.d.ts +13 -126
  51. package/dist/AutoUpdatedServerObjectClass.js +92 -315
  52. package/dist/AutoUpdatedServerObjectClass.js.map +1 -1
  53. package/dist/ClientTypes.d.ts +13 -0
  54. package/dist/ClientTypes.js +70 -0
  55. package/dist/ClientTypes.js.map +1 -0
  56. package/dist/CommonTypes.d.ts +3 -266
  57. package/dist/CommonTypes.js +4 -234
  58. package/dist/CommonTypes.js.map +1 -1
  59. package/dist/CommonTypes_server.d.ts +1 -1
  60. package/dist/CommonTypes_server.js +2 -1
  61. package/dist/CommonTypes_server.js.map +1 -1
  62. package/dist/ServerTypes.d.ts +13 -0
  63. package/dist/ServerTypes.js +78 -0
  64. package/dist/ServerTypes.js.map +1 -0
  65. package/dist/TestTypes.d.ts +1 -0
  66. package/dist/TestTypes.js +7 -0
  67. package/dist/TestTypes.js.map +1 -0
  68. package/dist/client.d.ts +1 -0
  69. package/dist/client.js +12 -0
  70. package/dist/client.js.map +1 -0
  71. package/dist/coverage/lcov-report/block-navigation.d.ts +1 -0
  72. package/dist/coverage/lcov-report/block-navigation.js +71 -0
  73. package/dist/coverage/lcov-report/block-navigation.js.map +1 -0
  74. package/dist/coverage/lcov-report/prettify.d.ts +0 -0
  75. package/dist/coverage/lcov-report/prettify.js +736 -0
  76. package/dist/coverage/lcov-report/prettify.js.map +1 -0
  77. package/dist/coverage/lcov-report/sorter.d.ts +1 -0
  78. package/dist/coverage/lcov-report/sorter.js +177 -0
  79. package/dist/coverage/lcov-report/sorter.js.map +1 -0
  80. package/dist/dist/AutoUpdateClientManagerClass.d.ts +19 -0
  81. package/dist/dist/AutoUpdateClientManagerClass.js +284 -0
  82. package/dist/dist/AutoUpdateClientManagerClass.js.map +1 -0
  83. package/dist/dist/AutoUpdateManagerClass.d.ts +23 -0
  84. package/dist/dist/AutoUpdateManagerClass.js +60 -0
  85. package/dist/dist/AutoUpdateManagerClass.js.map +1 -0
  86. package/dist/dist/AutoUpdateServerManagerClass.d.ts +50 -0
  87. package/dist/dist/AutoUpdateServerManagerClass.js +413 -0
  88. package/dist/dist/AutoUpdateServerManagerClass.js.map +1 -0
  89. package/dist/dist/AutoUpdatedClientObjectClass.d.ts +72 -0
  90. package/dist/dist/AutoUpdatedClientObjectClass.js +865 -0
  91. package/dist/dist/AutoUpdatedClientObjectClass.js.map +1 -0
  92. package/dist/dist/AutoUpdatedServerObjectClass.d.ts +15 -0
  93. package/dist/dist/AutoUpdatedServerObjectClass.js +124 -0
  94. package/dist/dist/AutoUpdatedServerObjectClass.js.map +1 -0
  95. package/dist/dist/ClientTypes.d.ts +13 -0
  96. package/dist/dist/ClientTypes.js +71 -0
  97. package/dist/dist/ClientTypes.js.map +1 -0
  98. package/dist/dist/CommonTypes.d.ts +3 -0
  99. package/dist/dist/CommonTypes.js +20 -0
  100. package/dist/dist/CommonTypes.js.map +1 -0
  101. package/dist/dist/CommonTypes_server.d.ts +1 -0
  102. package/dist/dist/CommonTypes_server.js +4 -0
  103. package/dist/dist/CommonTypes_server.js.map +1 -0
  104. package/dist/dist/ServerTypes.d.ts +13 -0
  105. package/dist/dist/ServerTypes.js +79 -0
  106. package/dist/dist/ServerTypes.js.map +1 -0
  107. package/dist/dist/TestTypes.d.ts +1 -0
  108. package/dist/dist/TestTypes.js +8 -0
  109. package/dist/dist/TestTypes.js.map +1 -0
  110. package/dist/dist/client.d.ts +1 -0
  111. package/dist/dist/client.js +13 -0
  112. package/dist/dist/client.js.map +1 -0
  113. package/dist/dist/coverage/lcov-report/block-navigation.d.ts +1 -0
  114. package/dist/dist/coverage/lcov-report/block-navigation.js +71 -0
  115. package/dist/dist/coverage/lcov-report/block-navigation.js.map +1 -0
  116. package/dist/dist/coverage/lcov-report/prettify.d.ts +0 -0
  117. package/dist/dist/coverage/lcov-report/prettify.js +736 -0
  118. package/dist/dist/coverage/lcov-report/prettify.js.map +1 -0
  119. package/dist/dist/coverage/lcov-report/sorter.d.ts +1 -0
  120. package/dist/dist/coverage/lcov-report/sorter.js +177 -0
  121. package/dist/dist/coverage/lcov-report/sorter.js.map +1 -0
  122. package/dist/dist/dist/AutoUpdateClientManagerClass.d.ts +19 -0
  123. package/dist/dist/dist/AutoUpdateClientManagerClass.js +285 -0
  124. package/dist/dist/dist/AutoUpdateClientManagerClass.js.map +1 -0
  125. package/dist/dist/dist/AutoUpdateManagerClass.d.ts +23 -0
  126. package/dist/dist/dist/AutoUpdateManagerClass.js +61 -0
  127. package/dist/dist/dist/AutoUpdateManagerClass.js.map +1 -0
  128. package/dist/dist/dist/AutoUpdateServerManagerClass.d.ts +158 -0
  129. package/dist/dist/dist/AutoUpdateServerManagerClass.js +414 -0
  130. package/dist/dist/dist/AutoUpdateServerManagerClass.js.map +1 -0
  131. package/dist/dist/dist/AutoUpdatedClientObjectClass.d.ts +72 -0
  132. package/dist/dist/dist/AutoUpdatedClientObjectClass.js +866 -0
  133. package/dist/dist/dist/AutoUpdatedClientObjectClass.js.map +1 -0
  134. package/dist/dist/dist/AutoUpdatedServerObjectClass.d.ts +15 -0
  135. package/dist/dist/dist/AutoUpdatedServerObjectClass.js +125 -0
  136. package/dist/dist/dist/AutoUpdatedServerObjectClass.js.map +1 -0
  137. package/dist/dist/dist/ClientTypes.d.ts +13 -0
  138. package/dist/dist/dist/ClientTypes.js +72 -0
  139. package/dist/dist/dist/ClientTypes.js.map +1 -0
  140. package/dist/dist/dist/CommonTypes.d.ts +3 -0
  141. package/dist/dist/dist/CommonTypes.js +21 -0
  142. package/dist/dist/dist/CommonTypes.js.map +1 -0
  143. package/dist/dist/dist/CommonTypes_server.d.ts +1 -0
  144. package/dist/dist/dist/CommonTypes_server.js +5 -0
  145. package/dist/dist/dist/CommonTypes_server.js.map +1 -0
  146. package/dist/dist/dist/ServerTypes.d.ts +13 -0
  147. package/dist/dist/dist/ServerTypes.js +80 -0
  148. package/dist/dist/dist/ServerTypes.js.map +1 -0
  149. package/dist/dist/dist/TestTypes.d.ts +1 -0
  150. package/dist/dist/dist/TestTypes.js +9 -0
  151. package/dist/dist/dist/TestTypes.js.map +1 -0
  152. package/dist/dist/dist/client.d.ts +1 -0
  153. package/dist/dist/dist/client.js +14 -0
  154. package/dist/dist/dist/client.js.map +1 -0
  155. package/dist/dist/dist/coverage/lcov-report/block-navigation.d.ts +1 -0
  156. package/dist/dist/dist/coverage/lcov-report/block-navigation.js +71 -0
  157. package/dist/dist/dist/coverage/lcov-report/block-navigation.js.map +1 -0
  158. package/dist/dist/dist/coverage/lcov-report/prettify.d.ts +0 -0
  159. package/dist/dist/dist/coverage/lcov-report/prettify.js +736 -0
  160. package/dist/dist/dist/coverage/lcov-report/prettify.js.map +1 -0
  161. package/dist/dist/dist/coverage/lcov-report/sorter.d.ts +1 -0
  162. package/dist/dist/dist/coverage/lcov-report/sorter.js +177 -0
  163. package/dist/dist/dist/coverage/lcov-report/sorter.js.map +1 -0
  164. package/dist/dist/dist/expo-test/app/(tabs)/_layout.d.ts +1 -0
  165. package/dist/dist/dist/expo-test/app/(tabs)/_layout.js +27 -0
  166. package/dist/dist/dist/expo-test/app/(tabs)/_layout.js.map +1 -0
  167. package/dist/dist/dist/expo-test/app/(tabs)/explore.d.ts +1 -0
  168. package/dist/dist/dist/expo-test/app/(tabs)/explore.js +95 -0
  169. package/dist/dist/dist/expo-test/app/(tabs)/explore.js.map +1 -0
  170. package/dist/dist/dist/expo-test/app/(tabs)/index.d.ts +1 -0
  171. package/dist/dist/dist/expo-test/app/(tabs)/index.js +81 -0
  172. package/dist/dist/dist/expo-test/app/(tabs)/index.js.map +1 -0
  173. package/dist/dist/dist/expo-test/app/_layout.d.ts +4 -0
  174. package/dist/dist/dist/expo-test/app/_layout.js +22 -0
  175. package/dist/dist/dist/expo-test/app/_layout.js.map +1 -0
  176. package/dist/dist/dist/expo-test/app/modal.d.ts +1 -0
  177. package/dist/dist/dist/expo-test/app/modal.js +28 -0
  178. package/dist/dist/dist/expo-test/app/modal.js.map +1 -0
  179. package/dist/dist/dist/expo-test/components/external-link.d.ts +4 -0
  180. package/dist/dist/dist/expo-test/components/external-link.js +18 -0
  181. package/dist/dist/dist/expo-test/components/external-link.js.map +1 -0
  182. package/dist/dist/dist/expo-test/components/haptic-tab.d.ts +1 -0
  183. package/dist/dist/dist/expo-test/components/haptic-tab.js +15 -0
  184. package/dist/dist/dist/expo-test/components/haptic-tab.js.map +1 -0
  185. package/dist/dist/dist/expo-test/components/hello-wave.d.ts +1 -0
  186. package/dist/dist/dist/expo-test/components/hello-wave.js +19 -0
  187. package/dist/dist/dist/expo-test/components/hello-wave.js.map +1 -0
  188. package/dist/dist/dist/expo-test/components/parallax-scroll-view.d.ts +5 -0
  189. package/dist/dist/dist/expo-test/components/parallax-scroll-view.js +53 -0
  190. package/dist/dist/dist/expo-test/components/parallax-scroll-view.js.map +1 -0
  191. package/dist/dist/dist/expo-test/components/themed-text.d.ts +7 -0
  192. package/dist/dist/dist/expo-test/components/themed-text.js +43 -0
  193. package/dist/dist/dist/expo-test/components/themed-text.js.map +1 -0
  194. package/dist/dist/dist/expo-test/components/themed-view.d.ts +6 -0
  195. package/dist/dist/dist/expo-test/components/themed-view.js +10 -0
  196. package/dist/dist/dist/expo-test/components/themed-view.js.map +1 -0
  197. package/dist/dist/dist/expo-test/components/ui/collapsible.d.ts +4 -0
  198. package/dist/dist/dist/expo-test/components/ui/collapsible.js +34 -0
  199. package/dist/dist/dist/expo-test/components/ui/collapsible.js.map +1 -0
  200. package/dist/dist/dist/expo-test/components/ui/icon-symbol.d.ts +11 -0
  201. package/dist/dist/dist/expo-test/components/ui/icon-symbol.ios.d.ts +7 -0
  202. package/dist/dist/dist/expo-test/components/ui/icon-symbol.ios.js +14 -0
  203. package/dist/dist/dist/expo-test/components/ui/icon-symbol.ios.js.map +1 -0
  204. package/dist/dist/dist/expo-test/components/ui/icon-symbol.js +25 -0
  205. package/dist/dist/dist/expo-test/components/ui/icon-symbol.js.map +1 -0
  206. package/dist/dist/dist/expo-test/constants/theme.d.ts +26 -0
  207. package/dist/dist/dist/expo-test/constants/theme.js +53 -0
  208. package/dist/dist/dist/expo-test/constants/theme.js.map +1 -0
  209. package/dist/dist/dist/expo-test/eslint.config.d.ts +2 -0
  210. package/dist/dist/dist/expo-test/eslint.config.js +11 -0
  211. package/dist/dist/dist/expo-test/eslint.config.js.map +1 -0
  212. package/dist/dist/dist/expo-test/hooks/use-color-scheme.d.ts +1 -0
  213. package/dist/dist/dist/expo-test/hooks/use-color-scheme.js +5 -0
  214. package/dist/dist/dist/expo-test/hooks/use-color-scheme.js.map +1 -0
  215. package/dist/dist/dist/expo-test/hooks/use-color-scheme.web.d.ts +4 -0
  216. package/dist/dist/dist/expo-test/hooks/use-color-scheme.web.js +20 -0
  217. package/dist/dist/dist/expo-test/hooks/use-color-scheme.web.js.map +1 -0
  218. package/dist/dist/dist/expo-test/hooks/use-theme-color.d.ts +1 -0
  219. package/dist/dist/dist/expo-test/hooks/use-theme-color.js +20 -0
  220. package/dist/dist/dist/expo-test/hooks/use-theme-color.js.map +1 -0
  221. package/dist/dist/dist/expo-test/scripts/reset-project.d.ts +2 -0
  222. package/dist/dist/dist/expo-test/scripts/reset-project.js +98 -0
  223. package/dist/dist/dist/expo-test/scripts/reset-project.js.map +1 -0
  224. package/dist/dist/dist/jest.config.d.ts +21 -0
  225. package/dist/dist/dist/jest.config.js +20 -0
  226. package/dist/dist/dist/jest.config.js.map +1 -0
  227. package/dist/dist/dist/server.d.ts +1 -0
  228. package/dist/dist/dist/server.js +16 -0
  229. package/dist/dist/dist/server.js.map +1 -0
  230. package/dist/dist/dist/socket_test.d.ts +1 -0
  231. package/dist/dist/dist/socket_test.js +24 -0
  232. package/dist/dist/dist/socket_test.js.map +1 -0
  233. package/dist/dist/dist/test.d.ts +1 -0
  234. package/dist/dist/dist/test.js +7 -0
  235. package/dist/dist/dist/test.js.map +1 -0
  236. package/dist/dist/dist/test_client.d.ts +1 -0
  237. package/dist/dist/dist/test_client.js +26 -0
  238. package/dist/dist/dist/test_client.js.map +1 -0
  239. package/dist/dist/dist/test_lib.d.ts +2 -0
  240. package/dist/dist/dist/test_lib.js +85 -0
  241. package/dist/dist/dist/test_lib.js.map +1 -0
  242. package/dist/dist/dist/test_server.d.ts +1 -0
  243. package/dist/dist/dist/test_server.js +54 -0
  244. package/dist/dist/dist/test_server.js.map +1 -0
  245. package/dist/dist/dist/tests/dem.test.d.ts +1 -0
  246. package/dist/dist/dist/tests/dem.test.js +341 -0
  247. package/dist/dist/dist/tests/dem.test.js.map +1 -0
  248. package/dist/dist/expo-test/app/(tabs)/_layout.d.ts +1 -0
  249. package/dist/dist/expo-test/app/(tabs)/_layout.js +26 -0
  250. package/dist/dist/expo-test/app/(tabs)/_layout.js.map +1 -0
  251. package/dist/dist/expo-test/app/(tabs)/explore.d.ts +1 -0
  252. package/dist/dist/expo-test/app/(tabs)/explore.js +94 -0
  253. package/dist/dist/expo-test/app/(tabs)/explore.js.map +1 -0
  254. package/dist/dist/expo-test/app/(tabs)/index.d.ts +1 -0
  255. package/dist/dist/expo-test/app/(tabs)/index.js +80 -0
  256. package/dist/dist/expo-test/app/(tabs)/index.js.map +1 -0
  257. package/dist/dist/expo-test/app/_layout.d.ts +4 -0
  258. package/dist/dist/expo-test/app/_layout.js +21 -0
  259. package/dist/dist/expo-test/app/_layout.js.map +1 -0
  260. package/dist/dist/expo-test/app/modal.d.ts +1 -0
  261. package/dist/dist/expo-test/app/modal.js +27 -0
  262. package/dist/dist/expo-test/app/modal.js.map +1 -0
  263. package/dist/dist/expo-test/components/external-link.d.ts +4 -0
  264. package/dist/dist/expo-test/components/external-link.js +17 -0
  265. package/dist/dist/expo-test/components/external-link.js.map +1 -0
  266. package/dist/dist/expo-test/components/haptic-tab.d.ts +1 -0
  267. package/dist/dist/expo-test/components/haptic-tab.js +14 -0
  268. package/dist/dist/expo-test/components/haptic-tab.js.map +1 -0
  269. package/dist/dist/expo-test/components/hello-wave.d.ts +1 -0
  270. package/dist/dist/expo-test/components/hello-wave.js +18 -0
  271. package/dist/dist/expo-test/components/hello-wave.js.map +1 -0
  272. package/dist/dist/expo-test/components/parallax-scroll-view.d.ts +5 -0
  273. package/dist/dist/expo-test/components/parallax-scroll-view.js +52 -0
  274. package/dist/dist/expo-test/components/parallax-scroll-view.js.map +1 -0
  275. package/dist/dist/expo-test/components/themed-text.d.ts +7 -0
  276. package/dist/dist/expo-test/components/themed-text.js +42 -0
  277. package/dist/dist/expo-test/components/themed-text.js.map +1 -0
  278. package/dist/dist/expo-test/components/themed-view.d.ts +6 -0
  279. package/dist/dist/expo-test/components/themed-view.js +9 -0
  280. package/dist/dist/expo-test/components/themed-view.js.map +1 -0
  281. package/dist/dist/expo-test/components/ui/collapsible.d.ts +4 -0
  282. package/dist/dist/expo-test/components/ui/collapsible.js +33 -0
  283. package/dist/dist/expo-test/components/ui/collapsible.js.map +1 -0
  284. package/dist/dist/expo-test/components/ui/icon-symbol.d.ts +11 -0
  285. package/dist/dist/expo-test/components/ui/icon-symbol.ios.d.ts +7 -0
  286. package/dist/dist/expo-test/components/ui/icon-symbol.ios.js +13 -0
  287. package/dist/dist/expo-test/components/ui/icon-symbol.ios.js.map +1 -0
  288. package/dist/dist/expo-test/components/ui/icon-symbol.js +24 -0
  289. package/dist/dist/expo-test/components/ui/icon-symbol.js.map +1 -0
  290. package/dist/dist/expo-test/constants/theme.d.ts +26 -0
  291. package/dist/dist/expo-test/constants/theme.js +52 -0
  292. package/dist/dist/expo-test/constants/theme.js.map +1 -0
  293. package/dist/dist/expo-test/eslint.config.d.ts +2 -0
  294. package/dist/dist/expo-test/eslint.config.js +11 -0
  295. package/dist/dist/expo-test/eslint.config.js.map +1 -0
  296. package/dist/dist/expo-test/hooks/use-color-scheme.d.ts +1 -0
  297. package/dist/dist/expo-test/hooks/use-color-scheme.js +4 -0
  298. package/dist/dist/expo-test/hooks/use-color-scheme.js.map +1 -0
  299. package/dist/dist/expo-test/hooks/use-color-scheme.web.d.ts +4 -0
  300. package/dist/dist/expo-test/hooks/use-color-scheme.web.js +19 -0
  301. package/dist/dist/expo-test/hooks/use-color-scheme.web.js.map +1 -0
  302. package/dist/dist/expo-test/hooks/use-theme-color.d.ts +1 -0
  303. package/dist/dist/expo-test/hooks/use-theme-color.js +19 -0
  304. package/dist/dist/expo-test/hooks/use-theme-color.js.map +1 -0
  305. package/dist/dist/expo-test/scripts/reset-project.d.ts +2 -0
  306. package/dist/dist/expo-test/scripts/reset-project.js +98 -0
  307. package/dist/dist/expo-test/scripts/reset-project.js.map +1 -0
  308. package/dist/dist/jest.config.d.ts +21 -0
  309. package/dist/dist/jest.config.js +19 -0
  310. package/dist/dist/jest.config.js.map +1 -0
  311. package/dist/dist/server.d.ts +1 -0
  312. package/dist/dist/server.js +15 -0
  313. package/dist/dist/server.js.map +1 -0
  314. package/dist/dist/socket_test.d.ts +1 -0
  315. package/dist/dist/socket_test.js +23 -0
  316. package/dist/dist/socket_test.js.map +1 -0
  317. package/dist/dist/test.d.ts +1 -0
  318. package/dist/dist/test.js +6 -0
  319. package/dist/dist/test.js.map +1 -0
  320. package/dist/dist/test_client.d.ts +1 -0
  321. package/dist/dist/test_client.js +25 -0
  322. package/dist/dist/test_client.js.map +1 -0
  323. package/dist/dist/test_lib.d.ts +2 -0
  324. package/dist/dist/test_lib.js +84 -0
  325. package/dist/dist/test_lib.js.map +1 -0
  326. package/dist/dist/test_server.d.ts +1 -0
  327. package/dist/dist/test_server.js +53 -0
  328. package/dist/dist/test_server.js.map +1 -0
  329. package/dist/dist/tests/dem.test.d.ts +1 -0
  330. package/dist/dist/tests/dem.test.js +340 -0
  331. package/dist/dist/tests/dem.test.js.map +1 -0
  332. package/dist/expo-test/app/(tabs)/_layout.d.ts +1 -0
  333. package/dist/expo-test/app/(tabs)/_layout.js +25 -0
  334. package/dist/expo-test/app/(tabs)/_layout.js.map +1 -0
  335. package/dist/expo-test/app/(tabs)/explore.d.ts +1 -0
  336. package/dist/expo-test/app/(tabs)/explore.js +93 -0
  337. package/dist/expo-test/app/(tabs)/explore.js.map +1 -0
  338. package/dist/expo-test/app/(tabs)/index.d.ts +1 -0
  339. package/dist/expo-test/app/(tabs)/index.js +79 -0
  340. package/dist/expo-test/app/(tabs)/index.js.map +1 -0
  341. package/dist/expo-test/app/_layout.d.ts +4 -0
  342. package/dist/expo-test/app/_layout.js +20 -0
  343. package/dist/expo-test/app/_layout.js.map +1 -0
  344. package/dist/expo-test/app/modal.d.ts +1 -0
  345. package/dist/expo-test/app/modal.js +26 -0
  346. package/dist/expo-test/app/modal.js.map +1 -0
  347. package/dist/expo-test/components/external-link.d.ts +4 -0
  348. package/dist/expo-test/components/external-link.js +16 -0
  349. package/dist/expo-test/components/external-link.js.map +1 -0
  350. package/dist/expo-test/components/haptic-tab.d.ts +1 -0
  351. package/dist/expo-test/components/haptic-tab.js +13 -0
  352. package/dist/expo-test/components/haptic-tab.js.map +1 -0
  353. package/dist/expo-test/components/hello-wave.d.ts +1 -0
  354. package/dist/expo-test/components/hello-wave.js +17 -0
  355. package/dist/expo-test/components/hello-wave.js.map +1 -0
  356. package/dist/expo-test/components/parallax-scroll-view.d.ts +5 -0
  357. package/dist/expo-test/components/parallax-scroll-view.js +51 -0
  358. package/dist/expo-test/components/parallax-scroll-view.js.map +1 -0
  359. package/dist/expo-test/components/themed-text.d.ts +7 -0
  360. package/dist/expo-test/components/themed-text.js +41 -0
  361. package/dist/expo-test/components/themed-text.js.map +1 -0
  362. package/dist/expo-test/components/themed-view.d.ts +6 -0
  363. package/dist/expo-test/components/themed-view.js +8 -0
  364. package/dist/expo-test/components/themed-view.js.map +1 -0
  365. package/dist/expo-test/components/ui/collapsible.d.ts +4 -0
  366. package/dist/expo-test/components/ui/collapsible.js +32 -0
  367. package/dist/expo-test/components/ui/collapsible.js.map +1 -0
  368. package/dist/expo-test/components/ui/icon-symbol.d.ts +11 -0
  369. package/dist/expo-test/components/ui/icon-symbol.ios.d.ts +7 -0
  370. package/dist/expo-test/components/ui/icon-symbol.ios.js +12 -0
  371. package/dist/expo-test/components/ui/icon-symbol.ios.js.map +1 -0
  372. package/dist/expo-test/components/ui/icon-symbol.js +23 -0
  373. package/dist/expo-test/components/ui/icon-symbol.js.map +1 -0
  374. package/dist/expo-test/constants/theme.d.ts +26 -0
  375. package/dist/expo-test/constants/theme.js +51 -0
  376. package/dist/expo-test/constants/theme.js.map +1 -0
  377. package/dist/expo-test/eslint.config.d.ts +2 -0
  378. package/dist/expo-test/eslint.config.js +11 -0
  379. package/dist/expo-test/eslint.config.js.map +1 -0
  380. package/dist/expo-test/hooks/use-color-scheme.d.ts +1 -0
  381. package/dist/expo-test/hooks/use-color-scheme.js +3 -0
  382. package/dist/expo-test/hooks/use-color-scheme.js.map +1 -0
  383. package/dist/expo-test/hooks/use-color-scheme.web.d.ts +4 -0
  384. package/dist/expo-test/hooks/use-color-scheme.web.js +18 -0
  385. package/dist/expo-test/hooks/use-color-scheme.web.js.map +1 -0
  386. package/dist/expo-test/hooks/use-theme-color.d.ts +1 -0
  387. package/dist/expo-test/hooks/use-theme-color.js +18 -0
  388. package/dist/expo-test/hooks/use-theme-color.js.map +1 -0
  389. package/dist/expo-test/scripts/reset-project.d.ts +2 -0
  390. package/dist/expo-test/scripts/reset-project.js +98 -0
  391. package/dist/expo-test/scripts/reset-project.js.map +1 -0
  392. package/dist/jest.config.d.ts +21 -0
  393. package/dist/jest.config.js +18 -0
  394. package/dist/jest.config.js.map +1 -0
  395. package/dist/server.d.ts +1 -8
  396. package/dist/server.js +13 -8
  397. package/dist/server.js.map +1 -1
  398. package/dist/socket_test.d.ts +1 -0
  399. package/dist/socket_test.js +22 -0
  400. package/dist/socket_test.js.map +1 -0
  401. package/dist/test.d.ts +1 -0
  402. package/dist/test.js +5 -0
  403. package/dist/test.js.map +1 -0
  404. package/dist/test_client.d.ts +1 -0
  405. package/dist/test_client.js +24 -0
  406. package/dist/test_client.js.map +1 -0
  407. package/dist/test_lib.d.ts +12 -0
  408. package/dist/test_lib.js +83 -0
  409. package/dist/test_lib.js.map +1 -0
  410. package/dist/test_server.d.ts +1 -0
  411. package/dist/test_server.js +52 -0
  412. package/dist/test_server.js.map +1 -0
  413. package/dist/tests/dem.test.d.ts +1 -0
  414. package/dist/tests/dem.test.js +339 -0
  415. package/dist/tests/dem.test.js.map +1 -0
  416. package/expo-test/app/(tabs)/_layout.d.ts +2 -0
  417. package/expo-test/app/(tabs)/_layout.js +24 -0
  418. package/expo-test/app/(tabs)/_layout.js.map +1 -0
  419. package/expo-test/app/(tabs)/explore.d.ts +1 -0
  420. package/expo-test/app/(tabs)/explore.js +92 -0
  421. package/expo-test/app/(tabs)/explore.js.map +1 -0
  422. package/expo-test/app/(tabs)/index.d.ts +1 -0
  423. package/expo-test/app/(tabs)/index.js +78 -0
  424. package/expo-test/app/(tabs)/index.js.map +1 -0
  425. package/expo-test/app/_layout.d.ts +5 -0
  426. package/expo-test/app/_layout.js +19 -0
  427. package/expo-test/app/_layout.js.map +1 -0
  428. package/expo-test/app/modal.d.ts +1 -0
  429. package/expo-test/app/modal.js +25 -0
  430. package/expo-test/app/modal.js.map +1 -0
  431. package/expo-test/components/external-link.d.ts +7 -0
  432. package/expo-test/components/external-link.js +15 -0
  433. package/expo-test/components/external-link.js.map +1 -0
  434. package/expo-test/components/haptic-tab.d.ts +2 -0
  435. package/expo-test/components/haptic-tab.js +12 -0
  436. package/expo-test/components/haptic-tab.js.map +1 -0
  437. package/expo-test/components/hello-wave.d.ts +1 -0
  438. package/expo-test/components/hello-wave.js +16 -0
  439. package/expo-test/components/hello-wave.js.map +1 -0
  440. package/expo-test/components/parallax-scroll-view.d.ts +10 -0
  441. package/expo-test/components/parallax-scroll-view.js +50 -0
  442. package/expo-test/components/parallax-scroll-view.js.map +1 -0
  443. package/expo-test/components/themed-text.d.ts +7 -0
  444. package/expo-test/components/themed-text.js +40 -0
  445. package/expo-test/components/themed-text.js.map +1 -0
  446. package/expo-test/components/themed-view.d.ts +6 -0
  447. package/expo-test/components/themed-view.js +7 -0
  448. package/expo-test/components/themed-view.js.map +1 -0
  449. package/expo-test/components/ui/collapsible.d.ts +4 -0
  450. package/expo-test/components/ui/collapsible.js +31 -0
  451. package/expo-test/components/ui/collapsible.js.map +1 -0
  452. package/expo-test/components/ui/icon-symbol.d.ts +25 -0
  453. package/expo-test/components/ui/icon-symbol.ios.d.ts +9 -0
  454. package/expo-test/components/ui/icon-symbol.ios.js +11 -0
  455. package/expo-test/components/ui/icon-symbol.ios.js.map +1 -0
  456. package/expo-test/components/ui/icon-symbol.js +22 -0
  457. package/expo-test/components/ui/icon-symbol.js.map +1 -0
  458. package/expo-test/constants/theme.d.ts +32 -0
  459. package/expo-test/constants/theme.js +50 -0
  460. package/expo-test/constants/theme.js.map +1 -0
  461. package/expo-test/eslint.config.d.ts +2 -0
  462. package/expo-test/eslint.config.js +11 -0
  463. package/expo-test/eslint.config.js.map +1 -0
  464. package/expo-test/hooks/use-color-scheme.d.ts +1 -0
  465. package/expo-test/hooks/use-color-scheme.js +2 -0
  466. package/expo-test/hooks/use-color-scheme.js.map +1 -0
  467. package/expo-test/hooks/use-color-scheme.web.d.ts +4 -0
  468. package/expo-test/hooks/use-color-scheme.web.js +17 -0
  469. package/expo-test/hooks/use-color-scheme.web.js.map +1 -0
  470. package/expo-test/hooks/use-theme-color.d.ts +9 -0
  471. package/expo-test/hooks/use-theme-color.js +17 -0
  472. package/expo-test/hooks/use-theme-color.js.map +1 -0
  473. package/expo-test/scripts/reset-project.d.ts +2 -0
  474. package/expo-test/scripts/reset-project.js +98 -0
  475. package/expo-test/scripts/reset-project.js.map +1 -0
  476. package/index.d.ts +4 -0
  477. package/index.js +5 -0
  478. package/index.js.map +1 -0
  479. package/jest.config.d.ts +3 -0
  480. package/jest.config.js +17 -0
  481. package/jest.config.js.map +1 -0
  482. package/package.json +23 -42
  483. package/server.d.ts +8 -0
  484. package/server.js +9 -0
  485. package/server.js.map +1 -0
  486. package/sync/ServerChangeTracker.js.map +1 -0
  487. package/version.d.ts +21 -0
  488. package/version.js +22 -0
  489. package/version.js.map +1 -0
  490. package/README.md +0 -18
  491. package/dist/sync/ServerChangeTracker.js.map +0 -1
  492. package/dist/tsconfig.tsbuildinfo +0 -1
  493. /package/{dist/DEMErrors.d.ts → DEMErrors.d.ts} +0 -0
  494. /package/{dist/DEMErrors.js → DEMErrors.js} +0 -0
  495. /package/{dist/sync → sync}/ClientStateReconciler.d.ts +0 -0
  496. /package/{dist/sync → sync}/ClientStateReconciler.js +0 -0
  497. /package/{dist/sync → sync}/ClientStateReconciler.js.map +0 -0
  498. /package/{dist/sync → sync}/ServerChangeTracker.d.ts +0 -0
  499. /package/{dist/sync → sync}/ServerChangeTracker.js +0 -0
  500. /package/{dist/sync → sync}/index.d.ts +0 -0
  501. /package/{dist/sync → sync}/index.js +0 -0
  502. /package/{dist/sync → sync}/index.js.map +0 -0
  503. /package/{dist/sync → sync}/storage/IClientStorageAdapter.d.ts +0 -0
  504. /package/{dist/sync → sync}/storage/IClientStorageAdapter.js +0 -0
  505. /package/{dist/sync → sync}/storage/IClientStorageAdapter.js.map +0 -0
  506. /package/{dist/sync → sync}/storage/IndexedDbStorageAdapter.d.ts +0 -0
  507. /package/{dist/sync → sync}/storage/IndexedDbStorageAdapter.js +0 -0
  508. /package/{dist/sync → sync}/storage/IndexedDbStorageAdapter.js.map +0 -0
  509. /package/{dist/sync → sync}/storage/LocalStorageAdapter.d.ts +0 -0
  510. /package/{dist/sync → sync}/storage/LocalStorageAdapter.js +0 -0
  511. /package/{dist/sync → sync}/storage/LocalStorageAdapter.js.map +0 -0
  512. /package/{dist/sync → sync}/storage/MemoryStorageAdapter.d.ts +0 -0
  513. /package/{dist/sync → sync}/storage/MemoryStorageAdapter.js +0 -0
  514. /package/{dist/sync → sync}/storage/MemoryStorageAdapter.js.map +0 -0
  515. /package/{dist/sync → sync}/types.d.ts +0 -0
  516. /package/{dist/sync → sync}/types.js +0 -0
  517. /package/{dist/sync → sync}/types.js.map +0 -0
@@ -0,0 +1,820 @@
1
+ import { AutoUpdateManager } from "./AutoUpdateManagerClass.js";
2
+ import { globalCache, EVENT_GET, EVENT_UPDATE, DEM_CLIENT_VERSION, verifyDEMVersion, DEMError, DEMErrorCode, } from "./CommonTypes.js";
3
+ import { EventEmitter } from "eventemitter3";
4
+ import { ClientStateReconciler, } from "./sync/index.js";
5
+ const inFlightFactories = new WeakMap();
6
+ /**
7
+ * Factory function initializing a dictionary of AutoUpdateClientManager instances.
8
+ * Verifies versions, executes startup handshakes, and parallelizes reference resolution.
9
+ *
10
+ * @param defs - Dictionary mapping entity class names to their client constructor classes.
11
+ * @param loggers - Logger callbacks interface.
12
+ * @param socket - Socket.IO client socket connection.
13
+ * @param doDebug - Flag indicating whether debug logs are emitted.
14
+ * @param emitter - Shared event emitter for lifecycle notifications.
15
+ * @param callbacks - Optional event callbacks (new, update, delete, progress).
16
+ * @param versionOptions - Version compatibility validation options.
17
+ * @param deltaSyncOptions - Delta sync storage and caching configuration.
18
+ * @returns Promise resolving to the initialized client manager map.
19
+ */
20
+ export async function AUCManagerFactory(defs, loggers, socket, doDebug = false, emitter = new EventEmitter(), callbacks = {}, versionOptions, deltaSyncOptions, lazyLoadingOptions) {
21
+ if (socket && inFlightFactories.has(socket)) {
22
+ loggers.debug?.("[DEM:FACTORY] Concurrent AUCManagerFactory detected on socket, reusing in-flight initialization promise.");
23
+ return inFlightFactories.get(socket);
24
+ }
25
+ const factoryPromise = (async () => {
26
+ const defaultCallbacks = {
27
+ new: callbacks.new ?? ((_x) => { }),
28
+ update: callbacks.update ??
29
+ ((_x, _y) => { }),
30
+ delete: callbacks.delete ?? ((_x) => { }),
31
+ progress: callbacks.progress ?? ((_x) => { }),
32
+ };
33
+ if (!doDebug) {
34
+ loggers.debug = (_) => { };
35
+ }
36
+ const managerKeys = Object.keys(defs);
37
+ const numberOfManagers = managerKeys.length || 1;
38
+ const progressUpdater = callbacks.progress ?? ((_x) => { });
39
+ // Immediately report initial 0 progress
40
+ progressUpdater(0);
41
+ const managerProgressMap = new Map();
42
+ for (const key of managerKeys) {
43
+ managerProgressMap.set(key, 0);
44
+ }
45
+ let lastReportedProgress = 0;
46
+ const updateOverallProgress = (managerKey, fraction) => {
47
+ const clampedFraction = Math.max(0, Math.min(1, fraction));
48
+ managerProgressMap.set(managerKey, clampedFraction);
49
+ let sum = 0;
50
+ for (const val of managerProgressMap.values()) {
51
+ sum += val;
52
+ }
53
+ const overall = sum / numberOfManagers;
54
+ if (overall >= lastReportedProgress || overall === 1) {
55
+ lastReportedProgress = overall;
56
+ progressUpdater(overall);
57
+ }
58
+ };
59
+ const managers = {};
60
+ const startStartTime = Date.now();
61
+ let startTime = Date.now();
62
+ for (const key in defs) {
63
+ try {
64
+ const Model = defs[key];
65
+ if (typeof Model !== "function") {
66
+ throw new DEMError(DEMErrorCode.INVALID_CONSTRUCTOR, `Invalid model constructor for manager: ${key}`);
67
+ }
68
+ const managerLazyOpts = typeof lazyLoadingOptions === "object" &&
69
+ lazyLoadingOptions !== null &&
70
+ key in lazyLoadingOptions
71
+ ? lazyLoadingOptions[key]
72
+ : lazyLoadingOptions;
73
+ const c = new AutoUpdateClientManager(Model, key, socket, loggers, managers, emitter, {
74
+ ...defaultCallbacks,
75
+ ...callbacks[key],
76
+ progress: (fraction) => {
77
+ callbacks[key]?.progress?.(fraction);
78
+ updateOverallProgress(key, fraction);
79
+ },
80
+ }, versionOptions, deltaSyncOptions, managerLazyOpts);
81
+ managers[key] = c;
82
+ }
83
+ catch (error) {
84
+ if (error instanceof Error &&
85
+ error.message.includes("Local type does not match server type for manager"))
86
+ throw error;
87
+ let message = `Creating manager for: ${key}`;
88
+ message += "\n Error creating manager: " + key;
89
+ message +=
90
+ "\n " + (error instanceof Error ? error.message : String(error));
91
+ loggers.error?.(message);
92
+ if (error instanceof Error && error.stack)
93
+ loggers.error?.(error.stack);
94
+ continue;
95
+ }
96
+ }
97
+ loggers.debug?.("Created all managers in " + (Date.now() - startTime) + "ms");
98
+ startTime = Date.now();
99
+ const loadPromises = Object.keys(defs).map(async (key) => {
100
+ let temp2 = { s: Date.now(), f: 0 };
101
+ try {
102
+ const manager = managers[key];
103
+ if (!manager) {
104
+ loggers.warn?.(`Manager ${key} was not created due to previous error`);
105
+ return;
106
+ }
107
+ await manager.loadFromServer(temp2);
108
+ loggers.debug?.("Loaded data from server for manager: " +
109
+ key +
110
+ " in " +
111
+ (temp2.f - temp2.s) +
112
+ "ms");
113
+ }
114
+ catch (error) {
115
+ if (error instanceof Error &&
116
+ error.message.includes("Local type does not match server type for manager"))
117
+ throw error;
118
+ let message = "Error loading data from server for manager: " + key;
119
+ message +=
120
+ "\n " + (error instanceof Error ? error.message : String(error));
121
+ message += "\n Failed in " + (temp2.f - temp2.s) + "ms";
122
+ loggers.error?.(message);
123
+ if (error instanceof Error && error.stack)
124
+ loggers.error?.(message + "\n" + error.stack);
125
+ }
126
+ });
127
+ await Promise.all(loadPromises);
128
+ // Ensure 100% progress emitted when all loaders finish
129
+ if (lastReportedProgress < 1) {
130
+ progressUpdater(1);
131
+ }
132
+ // Generate getters and setters for all client objects now that everything is loaded
133
+ for (const manager of Object.values(managers)) {
134
+ for (const obj of manager.objectsAsArray) {
135
+ obj.generateSettersAndGetters();
136
+ }
137
+ }
138
+ loggers.debug?.("Loaded data from server for all managers in " +
139
+ (Date.now() - startTime) +
140
+ "ms");
141
+ loggers.info?.("Loaded all managers in " + (Date.now() - startStartTime) + "ms");
142
+ return managers;
143
+ })();
144
+ if (socket) {
145
+ inFlightFactories.set(socket, factoryPromise);
146
+ }
147
+ try {
148
+ return await factoryPromise;
149
+ }
150
+ finally {
151
+ if (socket) {
152
+ inFlightFactories.delete(socket);
153
+ }
154
+ }
155
+ }
156
+ export class AutoUpdateClientManager extends AutoUpdateManager {
157
+ objects_ = {};
158
+ managers;
159
+ callbacks;
160
+ socket;
161
+ versionOptions;
162
+ deltaSyncOptions;
163
+ storageAdapter;
164
+ deltaSyncEnabled;
165
+ lazyLoadingOptions;
166
+ isLazyLoadingEnabled;
167
+ defaultHydrationDepth = 2;
168
+ manifest = [];
169
+ lastRevision = 0;
170
+ totalObjects = 0;
171
+ loadedObjects = 0;
172
+ pendingMissingFetches = new Map();
173
+ pendingHydrations = new Map();
174
+ _cachedObjectsArray = null;
175
+ _reconnectHandler;
176
+ /**
177
+ * Initializes an AutoUpdateClientManager instance.
178
+ *
179
+ * @param classParam - Constructor of the client object entity.
180
+ * @param className - Managed entity class name.
181
+ * @param socket - Socket.IO client socket connection.
182
+ * @param loggers - Logging interfaces.
183
+ * @param managers - Registry of sibling client managers.
184
+ * @param emitter - Shared event emitter.
185
+ * @param callbacks - Client event callbacks.
186
+ * @param versionOptions - Version compatibility options.
187
+ * @param deltaSyncOptions - Delta sync storage adapter configuration.
188
+ * @param lazyLoadingOptions - Lazy loading manifest and hydration configuration.
189
+ */
190
+ constructor(classParam, className, socket, loggers, managers, emitter, callbacks, versionOptions, deltaSyncOptions, lazyLoadingOptions) {
191
+ if (!classParam)
192
+ throw new DEMError(DEMErrorCode.MISSING_ARGUMENT, "Missing required argument: classParam");
193
+ if (!className)
194
+ throw new DEMError(DEMErrorCode.MISSING_ARGUMENT, "Missing required argument: className");
195
+ if (!socket)
196
+ throw new DEMError(DEMErrorCode.MISSING_ARGUMENT, "Missing required argument: socket");
197
+ super(classParam, className, socket, loggers, managers, emitter);
198
+ this.socket = socket;
199
+ this.managers = managers;
200
+ this.callbacks = callbacks;
201
+ this.versionOptions = versionOptions;
202
+ this.lazyLoadingOptions = lazyLoadingOptions;
203
+ if (typeof lazyLoadingOptions === "object") {
204
+ this.isLazyLoadingEnabled = lazyLoadingOptions.enabled !== false;
205
+ this.defaultHydrationDepth = lazyLoadingOptions.defaultDepth ?? 2;
206
+ }
207
+ else {
208
+ this.isLazyLoadingEnabled = Boolean(lazyLoadingOptions);
209
+ this.defaultHydrationDepth = 2;
210
+ }
211
+ if (deltaSyncOptions) {
212
+ this.deltaSyncEnabled = true;
213
+ if (typeof deltaSyncOptions === "object") {
214
+ this.deltaSyncOptions = deltaSyncOptions;
215
+ this.storageAdapter = deltaSyncOptions.storage;
216
+ }
217
+ }
218
+ else {
219
+ this.deltaSyncEnabled = false;
220
+ }
221
+ this._reconnectHandler = async () => {
222
+ this.loggers.info?.("Socket reconnected, reloading manager data from server...");
223
+ try {
224
+ await this.loadFromServer();
225
+ }
226
+ catch (err) {
227
+ this.loggers.error?.("Error reloading on reconnect: " +
228
+ (err instanceof Error ? err.message : String(err)));
229
+ }
230
+ };
231
+ this.socket?.on?.("reconnect", this._reconnectHandler);
232
+ }
233
+ /**
234
+ * Normalizes loaded object count against total objects into a 0 to 1 progress fraction.
235
+ *
236
+ * @param loaded - Number of loaded objects.
237
+ * @param total - Total count of expected objects.
238
+ * @returns Normalized progress value between 0 and 1.
239
+ */
240
+ normalizeProgress(loaded, total) {
241
+ if (!total || total <= 0)
242
+ return 1;
243
+ const ratio = loaded / total;
244
+ return Math.max(0, Math.min(1, ratio));
245
+ }
246
+ /**
247
+ * Registers socket event listeners for entity creation and deletion broadcasts.
248
+ */
249
+ startSocketListeners() {
250
+ this.socket.off("new" + this.className);
251
+ this.socket.off("delete" + this.className);
252
+ this.socket.on("new" + this.className, async (payload) => {
253
+ const id = typeof payload === "string" ? payload : payload._id;
254
+ if (this.getObject(id))
255
+ return;
256
+ this.loggers.debug("Applying new object from manager " + this.className + " - " + id);
257
+ try {
258
+ if (this.isLazyLoadingEnabled) {
259
+ const description = typeof payload === "object" && payload.description
260
+ ? payload.description
261
+ : id;
262
+ this.manifest.push({ _id: id, description });
263
+ const stub = new this.classParam(this.classParam, this.socket, { _id: id, __isLazyStub: true, descriptor: description }, this.loggers, this.className, this, this.callbacks, this.emitter);
264
+ stub.descriptor = description;
265
+ this.objects_[id] = stub;
266
+ globalCache.objects[id] = {
267
+ className: this.className,
268
+ object: stub,
269
+ };
270
+ this._cachedObjectsArray = null;
271
+ this.totalObjects += 1;
272
+ this.loadedObjects += 1;
273
+ this.callbacks.new(stub);
274
+ return;
275
+ }
276
+ this.totalObjects += 1;
277
+ await this.handleGetMissingObject(id);
278
+ this.loadedObjects += 1;
279
+ if (this.storageAdapter) {
280
+ await ClientStateReconciler.persistToStorage(this, this.lastRevision, this.storageAdapter);
281
+ }
282
+ }
283
+ catch (error) {
284
+ this.loggers.error("Error loading object " +
285
+ id +
286
+ " from manager " +
287
+ this.className +
288
+ " - " +
289
+ (error instanceof Error ? error.message : String(error)));
290
+ if (error instanceof Error && error.stack)
291
+ this.loggers.error(error.stack);
292
+ }
293
+ });
294
+ this.socket.on("delete" + this.className, async (id) => {
295
+ if (!this.getObject(id))
296
+ return;
297
+ this.loggers.debug("Applying object deletion from manager " + this.className + " - " + id);
298
+ try {
299
+ this.totalObjects -= 1;
300
+ this.loadedObjects -= 1;
301
+ await this.deleteObject(id);
302
+ }
303
+ catch (error) {
304
+ this.loggers.error("Error applying object deletion from manager " +
305
+ this.className +
306
+ " - " +
307
+ id);
308
+ this.loggers.error(error instanceof Error ? error.message : String(error));
309
+ if (error instanceof Error && error.stack)
310
+ this.loggers.error(error.stack);
311
+ }
312
+ });
313
+ }
314
+ /**
315
+ * Deletes an object by ID from local cache, socket events, and persistent storage adapter.
316
+ *
317
+ * @param _id - Identifier of object to delete.
318
+ * @returns Promise resolving to deletion outcome.
319
+ */
320
+ async deleteObject(_id) {
321
+ const _idStr = _id.toString();
322
+ this.socket.off(EVENT_UPDATE + this.className + _idStr);
323
+ this._cachedObjectsArray = null;
324
+ const res = await super.deleteObject(_id);
325
+ if (this.storageAdapter) {
326
+ await ClientStateReconciler.persistToStorage(this, this.lastRevision, this.storageAdapter);
327
+ }
328
+ return res;
329
+ }
330
+ /**
331
+ * Fetches startup data from the server or applies delta updates from local storage.
332
+ *
333
+ * @param t - Optional benchmark timer tracking object.
334
+ * @returns Promise resolving when data has been loaded and initialized.
335
+ */
336
+ async loadFromServer(t) {
337
+ let hasRestoredFromStorage = false;
338
+ if (this.storageAdapter && Object.keys(this.objects_).length === 0) {
339
+ const restored = await ClientStateReconciler.restoreFromStorage(this, this.storageAdapter);
340
+ if (restored.restored) {
341
+ hasRestoredFromStorage = true;
342
+ this.lastRevision = restored.revision;
343
+ this.loggers.debug?.(`Restored ${restored.count} objects from storage for ${this.className} (revision: ${this.lastRevision})`);
344
+ }
345
+ }
346
+ await new Promise((resolve, reject) => {
347
+ const timer = setTimeout(() => {
348
+ reject(new DEMError(DEMErrorCode.TIMEOUT, `Timeout waiting for startup data from server for ${this.className}`));
349
+ }, 5000);
350
+ const startupPayload = {
351
+ clientVersion: DEM_CLIENT_VERSION,
352
+ };
353
+ if (this.deltaSyncEnabled && hasRestoredFromStorage) {
354
+ startupPayload.lastRevision = this.lastRevision;
355
+ }
356
+ this.socket.emit("startup" + this.className, startupPayload, async (res) => {
357
+ clearTimeout(timer);
358
+ if (!res || !res.success) {
359
+ const err = res?.message || "Failed to load startup data";
360
+ this.loggers.error("Error loading ids from server for manager");
361
+ this.loggers.error(err);
362
+ reject(new DEMError(res?.code ?? DEMErrorCode.STARTUP_FAILED, err));
363
+ return;
364
+ }
365
+ const data = res.data;
366
+ // DEM Version Verification
367
+ if (data.version) {
368
+ const verResult = verifyDEMVersion(DEM_CLIENT_VERSION, data.version, this.versionOptions);
369
+ if (!verResult.compatible) {
370
+ const errMsg = verResult.message ||
371
+ `DEM Version Incompatibility: Client (${DEM_CLIENT_VERSION}) is incompatible with Server (${data.version})`;
372
+ this.loggers.error?.(errMsg);
373
+ this.versionOptions?.onVersionMismatch?.(DEM_CLIENT_VERSION, data.version, errMsg);
374
+ reject(new DEMError(DEMErrorCode.VERSION_MISMATCH, errMsg));
375
+ return;
376
+ }
377
+ else if (verResult.status !== "match") {
378
+ this.loggers.warn?.(verResult.message);
379
+ this.versionOptions?.onVersionMismatch?.(DEM_CLIENT_VERSION, data.version, verResult.message);
380
+ }
381
+ }
382
+ else {
383
+ this.loggers.debug?.(`Connected to DEM server for ${this.className} without version payload.`);
384
+ if (this.versionOptions?.strictVersionMatch) {
385
+ const errMsg = `Strict DEM version match required for ${this.className}, but server did not provide a version.`;
386
+ this.loggers.error?.(errMsg);
387
+ reject(new DEMError(DEMErrorCode.VERSION_MISMATCH, errMsg));
388
+ return;
389
+ }
390
+ }
391
+ if (data.status === "up-to-date") {
392
+ this.lastRevision = data.revision ?? this.lastRevision;
393
+ this.callbacks.progress?.(1);
394
+ this.startSocketListeners();
395
+ this.isLoaded_ = true;
396
+ if (t)
397
+ t.f = Date.now();
398
+ resolve();
399
+ return;
400
+ }
401
+ if (data.status === "delta" && data.changes) {
402
+ this.lastRevision = data.revision ?? this.lastRevision;
403
+ await ClientStateReconciler.applyDelta(this, data, this.storageAdapter);
404
+ this.callbacks.progress?.(1);
405
+ this.startSocketListeners();
406
+ this.isLoaded_ = true;
407
+ if (t)
408
+ t.f = Date.now();
409
+ resolve();
410
+ return;
411
+ }
412
+ if (data.status === "lazy") {
413
+ this.lastRevision = data.revision ?? this.lastRevision;
414
+ this.manifest = data.manifest ?? [];
415
+ // Clear old objects before populating new stubs
416
+ for (const oldId of Object.keys(this.objects_)) {
417
+ delete globalCache.objects[oldId];
418
+ }
419
+ this.objects_ = {};
420
+ this._cachedObjectsArray = null;
421
+ const descMap = new Map();
422
+ if (data.manifest) {
423
+ for (const entry of data.manifest) {
424
+ descMap.set(String(entry._id), entry.description);
425
+ }
426
+ }
427
+ for (const id of data.ids) {
428
+ const description = descMap.get(String(id));
429
+ const stub = new this.classParam(this.classParam, this.socket, { _id: id, __isLazyStub: true, descriptor: description }, this.loggers, this.className, this, this.callbacks, this.emitter);
430
+ stub.descriptor = description;
431
+ this.objects_[id] = stub;
432
+ globalCache.objects[id] = {
433
+ className: this.className,
434
+ object: stub,
435
+ };
436
+ }
437
+ this.totalObjects = data.ids.length;
438
+ this.loadedObjects = data.ids.length;
439
+ this.callbacks.progress?.(1);
440
+ this.startSocketListeners();
441
+ this.isLoaded_ = true;
442
+ if (t)
443
+ t.f = Date.now();
444
+ resolve();
445
+ return;
446
+ }
447
+ // Full sync handling
448
+ const serverPropsCopy = [...data.properties];
449
+ let extraProperties = [];
450
+ for (const property of this.properties) {
451
+ if (typeof property !== "string")
452
+ throw new DEMError(DEMErrorCode.INVALID_ARGUMENT, "Only string keys allowed. Not this shit: " + String(property));
453
+ if (property === "_id")
454
+ continue;
455
+ if (serverPropsCopy.includes(property)) {
456
+ serverPropsCopy.splice(serverPropsCopy.indexOf(property), 1);
457
+ }
458
+ else {
459
+ extraProperties.push(property);
460
+ }
461
+ }
462
+ let { allowedToLoad, errorMessage } = this.checkLoadability(extraProperties, { properties: serverPropsCopy });
463
+ if (!allowedToLoad) {
464
+ this.loggers.error?.(errorMessage);
465
+ reject(new DEMError(DEMErrorCode.STARTUP_FAILED, errorMessage));
466
+ return;
467
+ }
468
+ this.loggers.debug("Loading manager DB " +
469
+ this.className +
470
+ " - [" +
471
+ data.ids.length +
472
+ "] entries");
473
+ if (this.loggers.debug && this.loggers.debug.toString().length > 15) {
474
+ this.loggers.debug(data.ids.join(", "));
475
+ }
476
+ // Clear old objects before populating new ones on full reload
477
+ for (const oldId of Object.keys(this.objects_)) {
478
+ delete globalCache.objects[oldId];
479
+ }
480
+ this.objects_ = {};
481
+ this._cachedObjectsArray = null;
482
+ this.totalObjects = data.ids.length;
483
+ this.loadedObjects = 0;
484
+ this.lastRevision = data.revision ?? 0;
485
+ if (data.ids.length === 0) {
486
+ this.callbacks.progress?.(1);
487
+ this.startSocketListeners();
488
+ this.isLoaded_ = true;
489
+ if (this.storageAdapter) {
490
+ await ClientStateReconciler.persistToStorage(this, this.lastRevision, this.storageAdapter);
491
+ }
492
+ if (t)
493
+ t.f = Date.now();
494
+ resolve();
495
+ return;
496
+ }
497
+ const objectMap = new Map();
498
+ if (data.objects) {
499
+ for (const objData of data.objects) {
500
+ if (objData?._id) {
501
+ objectMap.set(objData._id.toString(), objData);
502
+ }
503
+ }
504
+ }
505
+ for (const id of data.ids) {
506
+ try {
507
+ const objData = objectMap.get(id);
508
+ this.objects_[id] = new this.classParam(this.classParam, this.socket, objData || id, this.loggers, this.className, this, this.callbacks, this.emitter);
509
+ globalCache.objects[id] = {
510
+ className: this.className,
511
+ object: this.objects_[id],
512
+ };
513
+ }
514
+ catch (error) {
515
+ this.loggers.error("Error loading object " +
516
+ id +
517
+ " from manager " +
518
+ this.className +
519
+ " - " +
520
+ (error instanceof Error ? error.message : String(error)));
521
+ if (error instanceof Error && error.stack)
522
+ this.loggers.error(error.stack);
523
+ }
524
+ }
525
+ const objectPromises = Object.keys(this.objects_).map(async (id) => {
526
+ const obj = this.objects_[id];
527
+ try {
528
+ await obj.isPreLoadedAsync();
529
+ await obj.loadMissingReferences();
530
+ this.loadedObjects += 1;
531
+ if (this.totalObjects < 100 ||
532
+ this.loadedObjects % Math.ceil(this.totalObjects / 100) === 0 ||
533
+ this.loadedObjects === this.totalObjects) {
534
+ this.callbacks.progress(this.normalizeProgress(this.loadedObjects, this.totalObjects));
535
+ }
536
+ }
537
+ catch (error) {
538
+ this.loggers.error("Error loading object " +
539
+ id +
540
+ " from manager " +
541
+ this.className +
542
+ " - " +
543
+ (error instanceof Error ? error.message : String(error)));
544
+ if (error instanceof Error && error.stack)
545
+ this.loggers.error(error.stack);
546
+ }
547
+ });
548
+ await Promise.all(objectPromises);
549
+ if (this.storageAdapter) {
550
+ await ClientStateReconciler.persistToStorage(this, this.lastRevision, this.storageAdapter);
551
+ }
552
+ this.loggers.info("Loaded " +
553
+ this.className +
554
+ " - [" +
555
+ Object.keys(this.objects_).length +
556
+ "] entries");
557
+ this.startSocketListeners();
558
+ this.isLoaded_ = true;
559
+ resolve();
560
+ });
561
+ });
562
+ if (t)
563
+ t.f = Date.now();
564
+ }
565
+ /**
566
+ * Verifies structural schema compatibility between client and server class definitions.
567
+ *
568
+ * @param extraProperties - Properties present on client class but absent on server.
569
+ * @param data - Server schema containing registered server property names.
570
+ * @returns Object indicating whether manager is allowed to load and descriptive error message.
571
+ */
572
+ checkLoadability(extraProperties, data) {
573
+ let allowedToLoad = true;
574
+ let errorMessage = "Local type does not match server type for manager " + this.className;
575
+ if (extraProperties.length > 0) {
576
+ allowedToLoad = false;
577
+ errorMessage +=
578
+ "\n\nLocal type has " +
579
+ (extraProperties.length > 1
580
+ ? "these extra properties"
581
+ : "this extra property") +
582
+ ":\n" +
583
+ extraProperties.join("\n");
584
+ }
585
+ const filteredProperties = data.properties.filter((p) => p !== "_id");
586
+ if (filteredProperties.length > 0) {
587
+ allowedToLoad = false;
588
+ errorMessage +=
589
+ "\n\nLocal type is missing " +
590
+ (filteredProperties.length > 1 ? "these properties" : "this property") +
591
+ ":\n" +
592
+ filteredProperties.join("\n");
593
+ }
594
+ return { allowedToLoad, errorMessage };
595
+ }
596
+ /**
597
+ * Retrieves an object from local memory by identifier.
598
+ *
599
+ * @param _id - Entity identifier.
600
+ * @returns Managed object instance, null, or undefined.
601
+ */
602
+ getObject(_id) {
603
+ if (!_id)
604
+ return null;
605
+ return this.objects_[_id.toString()] || undefined;
606
+ }
607
+ /**
608
+ * Dictionary map containing all managed object instances keyed by ID string.
609
+ *
610
+ * @returns Object dictionary keyed by string IDs.
611
+ */
612
+ get objects() {
613
+ return this.objects_;
614
+ }
615
+ /**
616
+ * Array representation of all managed object instances, cached for fast reads.
617
+ *
618
+ * @returns Array containing all managed object instances.
619
+ */
620
+ get objectsAsArray() {
621
+ if (!this._cachedObjectsArray) {
622
+ this._cachedObjectsArray = Object.values(this.objects_);
623
+ }
624
+ return this._cachedObjectsArray;
625
+ }
626
+ /**
627
+ * Loads and hydrates an unhydrated entity on demand up to a designated reference depth.
628
+ * Deduplicates concurrent in-flight hydration requests.
629
+ *
630
+ * @param _id - Unique identifier of the entity to hydrate.
631
+ * @param options - Hydration options containing target reference depth.
632
+ * @returns Promise resolving to the hydrated entity instance.
633
+ */
634
+ async loadObject(_id, options) {
635
+ const _idStr = _id.toString();
636
+ const existing = this.objects_[_idStr];
637
+ if (existing && !existing.isLazyStub && existing.isLoaded) {
638
+ return existing;
639
+ }
640
+ if (this.pendingHydrations.has(_idStr)) {
641
+ return this.pendingHydrations.get(_idStr);
642
+ }
643
+ const depth = options?.depth ??
644
+ (typeof this.lazyLoadingOptions === "object"
645
+ ? this.lazyLoadingOptions.defaultDepth
646
+ : undefined) ??
647
+ this.defaultHydrationDepth ??
648
+ 2;
649
+ const hydrationPromise = (async () => {
650
+ try {
651
+ const response = await new Promise((resolve, reject) => {
652
+ this.socket.emit(EVENT_GET + this.className + _idStr, { depth }, (res) => {
653
+ if (!res || !res.success) {
654
+ const errMsg = res?.message || `Failed to fetch lazy object ${_idStr}`;
655
+ reject(new DEMError(res?.code ?? DEMErrorCode.OBJECT_LOAD_FAILED, errMsg));
656
+ return;
657
+ }
658
+ resolve(res);
659
+ });
660
+ });
661
+ const rootData = response.data;
662
+ let rootObj = this.objects_[_idStr];
663
+ const existingDescriptor = rootObj?.descriptor ?? this.manifest.find((m) => String(m._id) === _idStr)?.description;
664
+ if (rootObj && typeof rootObj.hydrateFromData === "function") {
665
+ rootObj.hydrateFromData(rootData);
666
+ }
667
+ else {
668
+ rootObj = new this.classParam(this.classParam, this.socket, rootData, this.loggers, this.className, this, this.callbacks, this.emitter);
669
+ this.objects_[_idStr] = rootObj;
670
+ globalCache.objects[_idStr] = {
671
+ className: this.className,
672
+ object: rootObj,
673
+ };
674
+ }
675
+ if (existingDescriptor) {
676
+ rootObj.descriptor = existingDescriptor;
677
+ }
678
+ // Hydrate related entities into respective sibling managers
679
+ if (response.related && typeof response.related === "object") {
680
+ for (const [targetClassName, entityList] of Object.entries(response.related)) {
681
+ const targetManager = this.managers?.[targetClassName];
682
+ if (targetManager && Array.isArray(entityList)) {
683
+ for (const entityData of entityList) {
684
+ if (!entityData?._id)
685
+ continue;
686
+ const entityIdStr = entityData._id.toString();
687
+ let targetObj = targetManager.objects_[entityIdStr];
688
+ if (targetObj && typeof targetObj.hydrateFromData === "function") {
689
+ targetObj.hydrateFromData(entityData);
690
+ }
691
+ else if (!targetObj) {
692
+ targetObj = new targetManager.classParam(targetManager.classParam, targetManager.socket, entityData, targetManager.loggers, targetManager.className, targetManager, targetManager.callbacks, targetManager.emitter);
693
+ targetManager.objects_[entityIdStr] = targetObj;
694
+ globalCache.objects[entityIdStr] = {
695
+ className: targetManager.className,
696
+ object: targetObj,
697
+ };
698
+ }
699
+ }
700
+ }
701
+ }
702
+ }
703
+ // Resolve references on root object
704
+ await rootObj.isPreLoadedAsync();
705
+ await rootObj.loadMissingReferences();
706
+ this._cachedObjectsArray = null;
707
+ return rootObj;
708
+ }
709
+ finally {
710
+ this.pendingHydrations.delete(_idStr);
711
+ }
712
+ })();
713
+ this.pendingHydrations.set(_idStr, hydrationPromise);
714
+ return hydrationPromise;
715
+ }
716
+ /**
717
+ * Fetches an object missing from local client memory on demand from the server.
718
+ * Deduplicates concurrent in-flight requests for the same entity ID.
719
+ *
720
+ * @param _id - Entity identifier of the missing object.
721
+ * @returns Promise resolving to the retrieved object instance.
722
+ * @throws {DEMError} Throws DEMErrorCode.MISSING_ID or MANAGERS_NOT_INITIALIZED.
723
+ */
724
+ async handleGetMissingObject(_id) {
725
+ const _idStr = _id.toString();
726
+ if (this.getObject(_idStr))
727
+ return this.getObject(_idStr);
728
+ if (!_idStr)
729
+ throw new DEMError(DEMErrorCode.MISSING_ID, "No id.");
730
+ if (!this.managers)
731
+ throw new DEMError(DEMErrorCode.MANAGERS_NOT_INITIALIZED, `No managers.`);
732
+ if (this.objects_[_idStr])
733
+ return this.objects_[_idStr];
734
+ if (this.pendingMissingFetches.has(_idStr)) {
735
+ return this.pendingMissingFetches.get(_idStr);
736
+ }
737
+ const fetchPromise = (async () => {
738
+ try {
739
+ const object = new this.classParam(this.classParam, this.socket, _idStr, this.loggers, this.className, this, this.callbacks, this.emitter);
740
+ await object.waitForPreloaded();
741
+ if (object.loadError)
742
+ throw new DEMError(DEMErrorCode.OBJECT_LOAD_FAILED, object.loadError);
743
+ this.objects_[object._id.toString()] = object;
744
+ this._cachedObjectsArray = null;
745
+ globalCache.objects[object._id.toString()] = {
746
+ className: this.className,
747
+ object: object,
748
+ };
749
+ await object.isPreLoadedAsync();
750
+ await object.loadMissingReferences();
751
+ this.callbacks.new(object);
752
+ return object;
753
+ }
754
+ finally {
755
+ this.pendingMissingFetches.delete(_idStr);
756
+ }
757
+ })();
758
+ this.pendingMissingFetches.set(_idStr, fetchPromise);
759
+ return fetchPromise;
760
+ }
761
+ /**
762
+ * Creates a new object instance on the server and registers it in local manager state.
763
+ *
764
+ * @param data - Object property payload omitting `_id`.
765
+ * @returns Promise resolving to the newly created client entity.
766
+ * @throws {DEMError} Throws DEMErrorCode.OBJECT_CREATE_FAILED on failure.
767
+ */
768
+ async createObject(data) {
769
+ if (!this.managers)
770
+ throw new DEMError(DEMErrorCode.MANAGERS_NOT_INITIALIZED, `No managers.`);
771
+ this.loggers.debug("Creating new object from manager " + this.className);
772
+ let createdId = null;
773
+ try {
774
+ const object = new this.classParam(this.classParam, this.socket, data, this.loggers, this.className, this, this.callbacks, this.emitter);
775
+ await object.waitForPreloaded();
776
+ const id = object._id?.toString() ?? object.data?._id?.toString();
777
+ if (!id) {
778
+ throw new DEMError(DEMErrorCode.OBJECT_CREATE_FAILED, `Failed to create ${this.className}: Object _id is missing after preload.`);
779
+ }
780
+ createdId = id;
781
+ this.objects_[id] = object;
782
+ this._cachedObjectsArray = null;
783
+ globalCache.objects[id] = {
784
+ className: this.className,
785
+ object: object,
786
+ };
787
+ await this.objects_[id].isPreLoadedAsync();
788
+ await this.objects_[id].loadMissingReferences();
789
+ await this.objects_[id].contactChildren();
790
+ this.callbacks.new(this.objects_[id]);
791
+ return this.objects_[id];
792
+ }
793
+ catch (error) {
794
+ if (createdId) {
795
+ delete this.objects_[createdId];
796
+ delete globalCache.objects[createdId];
797
+ this._cachedObjectsArray = null;
798
+ }
799
+ this.loggers.error("Error creating new object from manager " + this.className);
800
+ this.loggers.error(error instanceof Error ? error.message : String(error));
801
+ throw error;
802
+ }
803
+ }
804
+ /**
805
+ * Closes the manager and unbinds all socket event listeners.
806
+ */
807
+ close() {
808
+ if (this._reconnectHandler) {
809
+ this.socket?.off?.("reconnect", this._reconnectHandler);
810
+ this._reconnectHandler = undefined;
811
+ }
812
+ this.socket?.off?.("new" + this.className);
813
+ this.socket?.off?.("delete" + this.className);
814
+ for (const id of this.objectIDs) {
815
+ this.socket?.off?.(EVENT_UPDATE + this.className + id);
816
+ }
817
+ super.close();
818
+ }
819
+ }
820
+ //# sourceMappingURL=AutoUpdateClientManagerClass.js.map