camera.ui3 0.0.34-alpha.6 → 0.0.35-test.2

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 (541) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/CONTRIBUTING.md +1 -0
  3. package/LICENSE.md +22 -0
  4. package/README.md +1 -0
  5. package/dist/{server/bin/cameraui.d.ts → cameraui.d.ts} +24 -17
  6. package/dist/{server/bin/cameraui.js → cameraui.js} +195 -208
  7. package/dist/cameraui.js.map +1 -0
  8. package/dist/installer/base.js.map +1 -0
  9. package/dist/{server/bin/installer → installer}/darwin.d.ts +0 -8
  10. package/dist/{server/bin/installer → installer}/darwin.js +9 -49
  11. package/dist/installer/darwin.js.map +1 -0
  12. package/dist/{server/bin/installer → installer}/freebsd.js +3 -2
  13. package/dist/installer/freebsd.js.map +1 -0
  14. package/dist/{server/bin/installer → installer}/linux.d.ts +1 -1
  15. package/dist/{server/bin/installer → installer}/linux.js +9 -24
  16. package/dist/installer/linux.js.map +1 -0
  17. package/dist/{server/bin/installer → installer}/win32.js +4 -2
  18. package/dist/installer/win32.js.map +1 -0
  19. package/dist/{server/bin/logger.js → logger.js} +2 -2
  20. package/dist/logger.js.map +1 -0
  21. package/dist/manager.d.ts +26 -0
  22. package/dist/manager.js +203 -0
  23. package/dist/manager.js.map +1 -0
  24. package/nodemon.json +14 -0
  25. package/package.json +21 -88
  26. package/dist/interface/@babel.l0sNRNKZ.0.0.34-alpha.6.js +0 -1
  27. package/dist/interface/@intlify.DXtFJcML.0.0.34-alpha.6.js +0 -15
  28. package/dist/interface/@mdi.C1UTQKuc.0.0.34-alpha.6.js +0 -1
  29. package/dist/interface/@react-dnd.CcwRs9xb.0.0.34-alpha.6.js +0 -1
  30. package/dist/interface/@socket.io.Dkula2eQ.0.0.34-alpha.6.js +0 -1
  31. package/dist/interface/@tanstack.COISQUaa.0.0.34-alpha.6.js +0 -1
  32. package/dist/interface/@turf.l0sNRNKZ.0.0.34-alpha.6.js +0 -1
  33. package/dist/interface/@vee-validate.vQEQxxhx.0.0.34-alpha.6.js +0 -5
  34. package/dist/interface/@vue.2olsU3zX.0.0.34-alpha.6.js +0 -17
  35. package/dist/interface/@vueform.CPzo51Ad.0.0.34-alpha.6.js +0 -1
  36. package/dist/interface/@vueuse.D9NHhWYc.0.0.34-alpha.6.js +0 -1
  37. package/dist/interface/@xterm.DqCFPTCA.0.0.34-alpha.6.js +0 -66
  38. package/dist/interface/Account.C8tdLL9c.0.0.34-alpha.6.js +0 -1
  39. package/dist/interface/Adminpanel.CCt65nrb.0.0.34-alpha.6.js +0 -2
  40. package/dist/interface/Appearance.HvJsFiT3.0.0.34-alpha.6.js +0 -1
  41. package/dist/interface/Backup.CSkOoG27.0.0.34-alpha.6.js +0 -1
  42. package/dist/interface/Camera.CpRZjMgc.0.0.34-alpha.6.js +0 -1
  43. package/dist/interface/Cameras.DjwMkoT7.0.0.34-alpha.6.js +0 -1
  44. package/dist/interface/Camview.o4nbp_Qw.0.0.34-alpha.6.js +0 -1
  45. package/dist/interface/Config.CQCi3KNu.0.0.34-alpha.6.js +0 -1
  46. package/dist/interface/Console.Dkyww3wB.0.0.34-alpha.6.js +0 -4
  47. package/dist/interface/FirstSteps.Bmr0_gA-.0.0.34-alpha.6.js +0 -1
  48. package/dist/interface/NewCamera.Bs1_J7Ad.0.0.34-alpha.6.js +0 -448
  49. package/dist/interface/Plugin.C8Vz5xoF.0.0.34-alpha.6.js +0 -1
  50. package/dist/interface/Plugins.CZL0KQFh.0.0.34-alpha.6.js +0 -1
  51. package/dist/interface/Recordings.B6pZqLF3.0.0.34-alpha.6.js +0 -1
  52. package/dist/interface/Recordings.BEvZE5cV.0.0.34-alpha.6.js +0 -1
  53. package/dist/interface/Settings.C997IgdZ.0.0.34-alpha.6.js +0 -1
  54. package/dist/interface/System.DuQ37voG.0.0.34-alpha.6.js +0 -4
  55. package/dist/interface/User.DlMcGeNz.0.0.34-alpha.6.js +0 -1
  56. package/dist/interface/VConfigEditor.vue_vue_type_script_setup_true_lang.xZXGs5pk.0.0.34-alpha.6.js +0 -2
  57. package/dist/interface/VConsole.DNiPpzW6.0.0.34-alpha.6.js +0 -1
  58. package/dist/interface/VPlayer.CUKkadJU.0.0.34-alpha.6.js +0 -4
  59. package/dist/interface/VPluginCard.B7M71ABH.0.0.34-alpha.6.js +0 -4
  60. package/dist/interface/ace-builds.DndaCQ18.0.0.34-alpha.6.js +0 -970
  61. package/dist/interface/apexcharts.6HWN1GNB.0.0.34-alpha.6.js +0 -795
  62. package/dist/interface/assets/@vueform.0.0.34-alpha.6.CroAHJs8.css +0 -1
  63. package/dist/interface/assets/@xterm.0.0.34-alpha.6.CFbL2ovg.css +0 -32
  64. package/dist/interface/assets/Account.0.0.34-alpha.6.J7oAjogS.css +0 -1
  65. package/dist/interface/assets/Adminpanel.0.0.34-alpha.6.a3t1v3MB.css +0 -1
  66. package/dist/interface/assets/Backup.0.0.34-alpha.6.CX0rT0QJ.css +0 -1
  67. package/dist/interface/assets/Camera.0.0.34-alpha.6.D1I-fW4q.css +0 -1
  68. package/dist/interface/assets/Cameras.0.0.34-alpha.6.Buf1Dgce.css +0 -1
  69. package/dist/interface/assets/Camview.0.0.34-alpha.6.B7Cja2ry.css +0 -1
  70. package/dist/interface/assets/Config.0.0.34-alpha.6.DNGo2krN.css +0 -1
  71. package/dist/interface/assets/Console.0.0.34-alpha.6.Bh8l9QnM.css +0 -1
  72. package/dist/interface/assets/FirstSteps.0.0.34-alpha.6.sPEcItZ6.css +0 -1
  73. package/dist/interface/assets/NewCamera.0.0.34-alpha.6.Cq8GzeJ7.css +0 -1
  74. package/dist/interface/assets/Plugin.0.0.34-alpha.6.DJbgaQc1.css +0 -1
  75. package/dist/interface/assets/Plugins.0.0.34-alpha.6.DXSoO9M1.css +0 -1
  76. package/dist/interface/assets/Settings.0.0.34-alpha.6.CVmui2kE.css +0 -1
  77. package/dist/interface/assets/User.0.0.34-alpha.6.BiGtIFqt.css +0 -1
  78. package/dist/interface/assets/VConsole.0.0.34-alpha.6.BCqKHpmJ.css +0 -1
  79. package/dist/interface/assets/VPlayer.0.0.34-alpha.6.DNtDNhfg.css +0 -1
  80. package/dist/interface/assets/VPluginCard.0.0.34-alpha.6.C8Lj6X-J.css +0 -1
  81. package/dist/interface/assets/highlight.0.0.34-alpha.6.Ch2EwETz.css +0 -1
  82. package/dist/interface/assets/logo-256.0.0.34-alpha.6.BCQk9H1-.png +0 -0
  83. package/dist/interface/assets/logo-512.0.0.34-alpha.6.DLKVOU2S.png +0 -0
  84. package/dist/interface/assets/logo.0.0.34-alpha.6.DmEiRk0z.png +0 -0
  85. package/dist/interface/assets/main.0.0.34-alpha.6.DNhh__S1.css +0 -1
  86. package/dist/interface/assets/mode-json.0.0.34-alpha.6.Br7xisR1.js +0 -275
  87. package/dist/interface/assets/mode-yaml.0.0.34-alpha.6.CIYL8U3d.js +0 -395
  88. package/dist/interface/assets/vue3-toastify.0.0.34-alpha.6.DHXAGmwn.css +0 -1
  89. package/dist/interface/assets/vuetify.0.0.34-alpha.6.CgGsw6iO.css +0 -5
  90. package/dist/interface/axios.C-n2IhIP.0.0.34-alpha.6.js +0 -6
  91. package/dist/interface/birpc.l0sNRNKZ.0.0.34-alpha.6.js +0 -1
  92. package/dist/interface/browserconfig.xml +0 -11
  93. package/dist/interface/compare-versions.DqEOhma6.0.0.34-alpha.6.js +0 -1
  94. package/dist/interface/dijkstrajs.D_NXgYpA.0.0.34-alpha.6.js +0 -1
  95. package/dist/interface/dnd-core.DjhjiPK9.0.0.34-alpha.6.js +0 -1
  96. package/dist/interface/draggabilly.CzAcRWAL.0.0.34-alpha.6.js +0 -6
  97. package/dist/interface/engine.io-client.CMjMz_QZ.0.0.34-alpha.6.js +0 -1
  98. package/dist/interface/engine.io-parser.BiEtp6m2.0.0.34-alpha.6.js +0 -1
  99. package/dist/interface/entities.C20TfXL6.0.0.34-alpha.6.js +0 -1
  100. package/dist/interface/ev-emitter.DdBIoR-C.0.0.34-alpha.6.js +0 -1
  101. package/dist/interface/fast-deep-equal.BPvnHGwn.0.0.34-alpha.6.js +0 -1
  102. package/dist/interface/fonts/Inter/Inter-Regular.ttf +0 -0
  103. package/dist/interface/get-size.D1dS-IaP.0.0.34-alpha.6.js +0 -5
  104. package/dist/interface/highlight.js.D0GppvQT.0.0.34-alpha.6.js +0 -2
  105. package/dist/interface/hookable.B8xFkYCm.0.0.34-alpha.6.js +0 -1
  106. package/dist/interface/index.html +0 -374
  107. package/dist/interface/linkify-it.BnwKCzGP.0.0.34-alpha.6.js +0 -1
  108. package/dist/interface/main.CjELdG9A.0.0.34-alpha.6.js +0 -5
  109. package/dist/interface/manifest.webmanifest +0 -1
  110. package/dist/interface/markdown-it.BmdsAkr5.0.0.34-alpha.6.js +0 -15
  111. package/dist/interface/mdurl.k9Sl0PQj.0.0.34-alpha.6.js +0 -2
  112. package/dist/interface/nprogress.CO0HPuzU.0.0.34-alpha.6.js +0 -2
  113. package/dist/interface/perfect-debounce.Cp2ysxOb.0.0.34-alpha.6.js +0 -1
  114. package/dist/interface/pinia.CBIup3aH.0.0.34-alpha.6.js +0 -5
  115. package/dist/interface/plugins.DkVCVMms.0.0.34-alpha.6.js +0 -1
  116. package/dist/interface/point-in-polygon-hao.l0sNRNKZ.0.0.34-alpha.6.js +0 -1
  117. package/dist/interface/punycode.js.Dj65hjkv.0.0.34-alpha.6.js +0 -1
  118. package/dist/interface/pwa/apple-splash-landscape-dark-1136x640.png +0 -0
  119. package/dist/interface/pwa/apple-splash-landscape-dark-1334x750.png +0 -0
  120. package/dist/interface/pwa/apple-splash-landscape-dark-1792x828.png +0 -0
  121. package/dist/interface/pwa/apple-splash-landscape-dark-2048x1536.png +0 -0
  122. package/dist/interface/pwa/apple-splash-landscape-dark-2160x1620.png +0 -0
  123. package/dist/interface/pwa/apple-splash-landscape-dark-2208x1242.png +0 -0
  124. package/dist/interface/pwa/apple-splash-landscape-dark-2224x1668.png +0 -0
  125. package/dist/interface/pwa/apple-splash-landscape-dark-2388x1668.png +0 -0
  126. package/dist/interface/pwa/apple-splash-landscape-dark-2436x1125.png +0 -0
  127. package/dist/interface/pwa/apple-splash-landscape-dark-2532x1170.png +0 -0
  128. package/dist/interface/pwa/apple-splash-landscape-dark-2556x1179.png +0 -0
  129. package/dist/interface/pwa/apple-splash-landscape-dark-2688x1242.png +0 -0
  130. package/dist/interface/pwa/apple-splash-landscape-dark-2732x2048.png +0 -0
  131. package/dist/interface/pwa/apple-splash-landscape-dark-2778x1284.png +0 -0
  132. package/dist/interface/pwa/apple-splash-landscape-dark-2796x1290.png +0 -0
  133. package/dist/interface/pwa/apple-splash-landscape-light-1136x640.png +0 -0
  134. package/dist/interface/pwa/apple-splash-landscape-light-1334x750.png +0 -0
  135. package/dist/interface/pwa/apple-splash-landscape-light-1792x828.png +0 -0
  136. package/dist/interface/pwa/apple-splash-landscape-light-2048x1536.png +0 -0
  137. package/dist/interface/pwa/apple-splash-landscape-light-2160x1620.png +0 -0
  138. package/dist/interface/pwa/apple-splash-landscape-light-2208x1242.png +0 -0
  139. package/dist/interface/pwa/apple-splash-landscape-light-2224x1668.png +0 -0
  140. package/dist/interface/pwa/apple-splash-landscape-light-2388x1668.png +0 -0
  141. package/dist/interface/pwa/apple-splash-landscape-light-2436x1125.png +0 -0
  142. package/dist/interface/pwa/apple-splash-landscape-light-2532x1170.png +0 -0
  143. package/dist/interface/pwa/apple-splash-landscape-light-2556x1179.png +0 -0
  144. package/dist/interface/pwa/apple-splash-landscape-light-2688x1242.png +0 -0
  145. package/dist/interface/pwa/apple-splash-landscape-light-2732x2048.png +0 -0
  146. package/dist/interface/pwa/apple-splash-landscape-light-2778x1284.png +0 -0
  147. package/dist/interface/pwa/apple-splash-landscape-light-2796x1290.png +0 -0
  148. package/dist/interface/pwa/apple-splash-portrait-dark-1125x2436.png +0 -0
  149. package/dist/interface/pwa/apple-splash-portrait-dark-1170x2532.png +0 -0
  150. package/dist/interface/pwa/apple-splash-portrait-dark-1179x2556.png +0 -0
  151. package/dist/interface/pwa/apple-splash-portrait-dark-1242x2208.png +0 -0
  152. package/dist/interface/pwa/apple-splash-portrait-dark-1242x2688.png +0 -0
  153. package/dist/interface/pwa/apple-splash-portrait-dark-1284x2778.png +0 -0
  154. package/dist/interface/pwa/apple-splash-portrait-dark-1290x2796.png +0 -0
  155. package/dist/interface/pwa/apple-splash-portrait-dark-1536x2048.png +0 -0
  156. package/dist/interface/pwa/apple-splash-portrait-dark-1620x2160.png +0 -0
  157. package/dist/interface/pwa/apple-splash-portrait-dark-1668x2224.png +0 -0
  158. package/dist/interface/pwa/apple-splash-portrait-dark-1668x2388.png +0 -0
  159. package/dist/interface/pwa/apple-splash-portrait-dark-2048x2732.png +0 -0
  160. package/dist/interface/pwa/apple-splash-portrait-dark-640x1136.png +0 -0
  161. package/dist/interface/pwa/apple-splash-portrait-dark-750x1334.png +0 -0
  162. package/dist/interface/pwa/apple-splash-portrait-dark-828x1792.png +0 -0
  163. package/dist/interface/pwa/apple-splash-portrait-light-1125x2436.png +0 -0
  164. package/dist/interface/pwa/apple-splash-portrait-light-1170x2532.png +0 -0
  165. package/dist/interface/pwa/apple-splash-portrait-light-1179x2556.png +0 -0
  166. package/dist/interface/pwa/apple-splash-portrait-light-1242x2208.png +0 -0
  167. package/dist/interface/pwa/apple-splash-portrait-light-1242x2688.png +0 -0
  168. package/dist/interface/pwa/apple-splash-portrait-light-1284x2778.png +0 -0
  169. package/dist/interface/pwa/apple-splash-portrait-light-1290x2796.png +0 -0
  170. package/dist/interface/pwa/apple-splash-portrait-light-1536x2048.png +0 -0
  171. package/dist/interface/pwa/apple-splash-portrait-light-1620x2160.png +0 -0
  172. package/dist/interface/pwa/apple-splash-portrait-light-1668x2224.png +0 -0
  173. package/dist/interface/pwa/apple-splash-portrait-light-1668x2388.png +0 -0
  174. package/dist/interface/pwa/apple-splash-portrait-light-2048x2732.png +0 -0
  175. package/dist/interface/pwa/apple-splash-portrait-light-640x1136.png +0 -0
  176. package/dist/interface/pwa/apple-splash-portrait-light-750x1334.png +0 -0
  177. package/dist/interface/pwa/apple-splash-portrait-light-828x1792.png +0 -0
  178. package/dist/interface/pwa/apple-touch-icon-180x180.png +0 -0
  179. package/dist/interface/pwa/favicon-16.ico +0 -0
  180. package/dist/interface/pwa/favicon-32.ico +0 -0
  181. package/dist/interface/pwa/favicon-48.ico +0 -0
  182. package/dist/interface/pwa/favicon-64.ico +0 -0
  183. package/dist/interface/pwa/logo.svg +0 -1
  184. package/dist/interface/pwa/maskable-icon-1240x600.png +0 -0
  185. package/dist/interface/pwa/maskable-icon-512x512.png +0 -0
  186. package/dist/interface/pwa/maskable-icon-620x300.png +0 -0
  187. package/dist/interface/pwa/pwa-1024x1024.png +0 -0
  188. package/dist/interface/pwa/pwa-120x120.png +0 -0
  189. package/dist/interface/pwa/pwa-144x144.png +0 -0
  190. package/dist/interface/pwa/pwa-152x152.png +0 -0
  191. package/dist/interface/pwa/pwa-167x167.png +0 -0
  192. package/dist/interface/pwa/pwa-180x180.png +0 -0
  193. package/dist/interface/pwa/pwa-192x192.png +0 -0
  194. package/dist/interface/pwa/pwa-24x24.png +0 -0
  195. package/dist/interface/pwa/pwa-300x300.png +0 -0
  196. package/dist/interface/pwa/pwa-36x36.png +0 -0
  197. package/dist/interface/pwa/pwa-48x48.png +0 -0
  198. package/dist/interface/pwa/pwa-50x50.png +0 -0
  199. package/dist/interface/pwa/pwa-64x64.png +0 -0
  200. package/dist/interface/pwa/pwa-72x72.png +0 -0
  201. package/dist/interface/pwa/pwa-88x88.png +0 -0
  202. package/dist/interface/pwa/pwa-96x96.png +0 -0
  203. package/dist/interface/qrcode.BgXQ059Y.0.0.34-alpha.6.js +0 -8
  204. package/dist/interface/react-dnd-html5-backend.1HQjlkwI.0.0.34-alpha.6.js +0 -2
  205. package/dist/interface/react-dnd-touch-backend.CuSdTpqi.0.0.34-alpha.6.js +0 -1
  206. package/dist/interface/redux.CuxFRhX_.0.0.34-alpha.6.js +0 -1
  207. package/dist/interface/registerSW.js +0 -1
  208. package/dist/interface/robots.txt +0 -2
  209. package/dist/interface/rxjs.DKQuv6LI.0.0.34-alpha.6.js +0 -3
  210. package/dist/interface/socket.io-client.Ba2QhaSK.0.0.34-alpha.6.js +0 -1
  211. package/dist/interface/socket.io-parser.CT0tlhnF.0.0.34-alpha.6.js +0 -1
  212. package/dist/interface/sw.js +0 -1
  213. package/dist/interface/sweepline-intersections.l0sNRNKZ.0.0.34-alpha.6.js +0 -1
  214. package/dist/interface/system.DBHlJaL3.0.0.34-alpha.6.js +0 -1
  215. package/dist/interface/tslib.9k7AwCpt.0.0.34-alpha.6.js +0 -1
  216. package/dist/interface/types.Cz9TaZAP.0.0.34-alpha.6.js +0 -1
  217. package/dist/interface/uc.micro.kMc2yuuw.0.0.34-alpha.6.js +0 -1
  218. package/dist/interface/unidragger.bJ3WxeD3.0.0.34-alpha.6.js +0 -5
  219. package/dist/interface/utils.mAKpSMLY.0.0.34-alpha.6.js +0 -1
  220. package/dist/interface/uuid.DvF23Exx.0.0.34-alpha.6.js +0 -1
  221. package/dist/interface/vee-validate.CghN0yPF.0.0.34-alpha.6.js +0 -5
  222. package/dist/interface/vue-i18n.DvwV0jjJ.0.0.34-alpha.6.js +0 -5
  223. package/dist/interface/vue-inline-svg.DXN-QH0U.0.0.34-alpha.6.js +0 -1
  224. package/dist/interface/vue-router.DbntwPAd.0.0.34-alpha.6.js +0 -5
  225. package/dist/interface/vue.l0sNRNKZ.0.0.34-alpha.6.js +0 -1
  226. package/dist/interface/vue3-apexcharts.Ep6IiXnK.0.0.34-alpha.6.js +0 -1
  227. package/dist/interface/vue3-dnd._duUsn6W.0.0.34-alpha.6.js +0 -1
  228. package/dist/interface/vue3-toastify.B0t5Ra1T.0.0.34-alpha.6.js +0 -1
  229. package/dist/interface/vuetify.dlIDGkOi.0.0.34-alpha.6.js +0 -5
  230. package/dist/interface/workbox-3e911b1d.js +0 -1
  231. package/dist/interface/zod.DnW1_kUe.0.0.34-alpha.6.js +0 -1
  232. package/dist/server/bin/cameraui.js.map +0 -1
  233. package/dist/server/bin/installer/base.js.map +0 -1
  234. package/dist/server/bin/installer/darwin.js.map +0 -1
  235. package/dist/server/bin/installer/freebsd.js.map +0 -1
  236. package/dist/server/bin/installer/linux.js.map +0 -1
  237. package/dist/server/bin/installer/win32.js.map +0 -1
  238. package/dist/server/bin/logger.js.map +0 -1
  239. package/dist/server/package.json +0 -139
  240. package/dist/server/requirements.txt +0 -14
  241. package/dist/server/src/api/controllers/api.controller.d.ts +0 -7
  242. package/dist/server/src/api/controllers/api.controller.js +0 -14
  243. package/dist/server/src/api/controllers/api.controller.js.map +0 -1
  244. package/dist/server/src/api/controllers/auth.controller.d.ts +0 -16
  245. package/dist/server/src/api/controllers/auth.controller.js +0 -233
  246. package/dist/server/src/api/controllers/auth.controller.js.map +0 -1
  247. package/dist/server/src/api/controllers/backup.controller.d.ts +0 -10
  248. package/dist/server/src/api/controllers/backup.controller.js +0 -52
  249. package/dist/server/src/api/controllers/backup.controller.js.map +0 -1
  250. package/dist/server/src/api/controllers/cameras.controller.d.ts +0 -38
  251. package/dist/server/src/api/controllers/cameras.controller.js +0 -632
  252. package/dist/server/src/api/controllers/cameras.controller.js.map +0 -1
  253. package/dist/server/src/api/controllers/config.controller.d.ts +0 -14
  254. package/dist/server/src/api/controllers/config.controller.js +0 -89
  255. package/dist/server/src/api/controllers/config.controller.js.map +0 -1
  256. package/dist/server/src/api/controllers/files.controller.d.ts +0 -8
  257. package/dist/server/src/api/controllers/files.controller.js +0 -28
  258. package/dist/server/src/api/controllers/files.controller.js.map +0 -1
  259. package/dist/server/src/api/controllers/frameWorkers.controller.d.ts +0 -11
  260. package/dist/server/src/api/controllers/frameWorkers.controller.js +0 -93
  261. package/dist/server/src/api/controllers/frameWorkers.controller.js.map +0 -1
  262. package/dist/server/src/api/controllers/plugins.controller.d.ts +0 -61
  263. package/dist/server/src/api/controllers/plugins.controller.js +0 -1353
  264. package/dist/server/src/api/controllers/plugins.controller.js.map +0 -1
  265. package/dist/server/src/api/controllers/system.controller.d.ts +0 -21
  266. package/dist/server/src/api/controllers/system.controller.js +0 -207
  267. package/dist/server/src/api/controllers/system.controller.js.map +0 -1
  268. package/dist/server/src/api/controllers/users.controller.d.ts +0 -28
  269. package/dist/server/src/api/controllers/users.controller.js +0 -509
  270. package/dist/server/src/api/controllers/users.controller.js.map +0 -1
  271. package/dist/server/src/api/database/checks.d.ts +0 -55
  272. package/dist/server/src/api/database/checks.js +0 -183
  273. package/dist/server/src/api/database/checks.js.map +0 -1
  274. package/dist/server/src/api/database/constants.d.ts +0 -8
  275. package/dist/server/src/api/database/constants.js +0 -9
  276. package/dist/server/src/api/database/constants.js.map +0 -1
  277. package/dist/server/src/api/database/index.d.ts +0 -31
  278. package/dist/server/src/api/database/index.js +0 -276
  279. package/dist/server/src/api/database/index.js.map +0 -1
  280. package/dist/server/src/api/database/migration.d.ts +0 -13
  281. package/dist/server/src/api/database/migration.js +0 -113
  282. package/dist/server/src/api/database/migration.js.map +0 -1
  283. package/dist/server/src/api/database/selfcheck.d.ts +0 -48
  284. package/dist/server/src/api/database/selfcheck.js +0 -397
  285. package/dist/server/src/api/database/selfcheck.js.map +0 -1
  286. package/dist/server/src/api/database/types.d.ts +0 -100
  287. package/dist/server/src/api/database/types.js +0 -2
  288. package/dist/server/src/api/database/types.js.map +0 -1
  289. package/dist/server/src/api/go2rtc/api/application.d.ts +0 -9
  290. package/dist/server/src/api/go2rtc/api/application.js +0 -39
  291. package/dist/server/src/api/go2rtc/api/application.js.map +0 -1
  292. package/dist/server/src/api/go2rtc/api/config.d.ts +0 -8
  293. package/dist/server/src/api/go2rtc/api/config.js +0 -44
  294. package/dist/server/src/api/go2rtc/api/config.js.map +0 -1
  295. package/dist/server/src/api/go2rtc/api/index.d.ts +0 -1
  296. package/dist/server/src/api/go2rtc/api/index.js +0 -29
  297. package/dist/server/src/api/go2rtc/api/index.js.map +0 -1
  298. package/dist/server/src/api/go2rtc/api/snapshot.d.ts +0 -8
  299. package/dist/server/src/api/go2rtc/api/snapshot.js +0 -34
  300. package/dist/server/src/api/go2rtc/api/snapshot.js.map +0 -1
  301. package/dist/server/src/api/go2rtc/api/streams.d.ts +0 -11
  302. package/dist/server/src/api/go2rtc/api/streams.js +0 -59
  303. package/dist/server/src/api/go2rtc/api/streams.js.map +0 -1
  304. package/dist/server/src/api/go2rtc/index.d.ts +0 -14
  305. package/dist/server/src/api/go2rtc/index.js +0 -30
  306. package/dist/server/src/api/go2rtc/index.js.map +0 -1
  307. package/dist/server/src/api/go2rtc/queue.d.ts +0 -10
  308. package/dist/server/src/api/go2rtc/queue.js +0 -38
  309. package/dist/server/src/api/go2rtc/queue.js.map +0 -1
  310. package/dist/server/src/api/go2rtc/types.d.ts +0 -92
  311. package/dist/server/src/api/go2rtc/types.js +0 -2
  312. package/dist/server/src/api/go2rtc/types.js.map +0 -1
  313. package/dist/server/src/api/index.d.ts +0 -20
  314. package/dist/server/src/api/index.js +0 -213
  315. package/dist/server/src/api/index.js.map +0 -1
  316. package/dist/server/src/api/middlewares/authPermission.middleware.d.ts +0 -5
  317. package/dist/server/src/api/middlewares/authPermission.middleware.js +0 -28
  318. package/dist/server/src/api/middlewares/authPermission.middleware.js.map +0 -1
  319. package/dist/server/src/api/middlewares/authValidation.middleware.d.ts +0 -4
  320. package/dist/server/src/api/middlewares/authValidation.middleware.js +0 -129
  321. package/dist/server/src/api/middlewares/authValidation.middleware.js.map +0 -1
  322. package/dist/server/src/api/middlewares/pagination.middleware.d.ts +0 -3
  323. package/dist/server/src/api/middlewares/pagination.middleware.js +0 -65
  324. package/dist/server/src/api/middlewares/pagination.middleware.js.map +0 -1
  325. package/dist/server/src/api/middlewares/socketAuth.middleware.d.ts +0 -41
  326. package/dist/server/src/api/middlewares/socketAuth.middleware.js +0 -81
  327. package/dist/server/src/api/middlewares/socketAuth.middleware.js.map +0 -1
  328. package/dist/server/src/api/plugins/header.plugin.d.ts +0 -2
  329. package/dist/server/src/api/plugins/header.plugin.js +0 -13
  330. package/dist/server/src/api/plugins/header.plugin.js.map +0 -1
  331. package/dist/server/src/api/plugins/logger.plugin.d.ts +0 -7
  332. package/dist/server/src/api/plugins/logger.plugin.js +0 -29
  333. package/dist/server/src/api/plugins/logger.plugin.js.map +0 -1
  334. package/dist/server/src/api/plugins/socket.plugin.d.ts +0 -11
  335. package/dist/server/src/api/plugins/socket.plugin.js +0 -12
  336. package/dist/server/src/api/plugins/socket.plugin.js.map +0 -1
  337. package/dist/server/src/api/plugins/system.plugin.d.ts +0 -18
  338. package/dist/server/src/api/plugins/system.plugin.js +0 -22
  339. package/dist/server/src/api/plugins/system.plugin.js.map +0 -1
  340. package/dist/server/src/api/plugins/useragent.plugin.d.ts +0 -8
  341. package/dist/server/src/api/plugins/useragent.plugin.js +0 -10
  342. package/dist/server/src/api/plugins/useragent.plugin.js.map +0 -1
  343. package/dist/server/src/api/routes/api.routes.d.ts +0 -2
  344. package/dist/server/src/api/routes/api.routes.js +0 -7
  345. package/dist/server/src/api/routes/api.routes.js.map +0 -1
  346. package/dist/server/src/api/routes/auth.routes.d.ts +0 -2
  347. package/dist/server/src/api/routes/auth.routes.js +0 -47
  348. package/dist/server/src/api/routes/auth.routes.js.map +0 -1
  349. package/dist/server/src/api/routes/backup.routes.d.ts +0 -2
  350. package/dist/server/src/api/routes/backup.routes.js +0 -23
  351. package/dist/server/src/api/routes/backup.routes.js.map +0 -1
  352. package/dist/server/src/api/routes/cameras.routes.d.ts +0 -2
  353. package/dist/server/src/api/routes/cameras.routes.js +0 -217
  354. package/dist/server/src/api/routes/cameras.routes.js.map +0 -1
  355. package/dist/server/src/api/routes/config.routes.d.ts +0 -2
  356. package/dist/server/src/api/routes/config.routes.js +0 -55
  357. package/dist/server/src/api/routes/config.routes.js.map +0 -1
  358. package/dist/server/src/api/routes/files.routes.d.ts +0 -2
  359. package/dist/server/src/api/routes/files.routes.js +0 -12
  360. package/dist/server/src/api/routes/files.routes.js.map +0 -1
  361. package/dist/server/src/api/routes/frameWorkers.routes.d.ts +0 -2
  362. package/dist/server/src/api/routes/frameWorkers.routes.js +0 -33
  363. package/dist/server/src/api/routes/frameWorkers.routes.js.map +0 -1
  364. package/dist/server/src/api/routes/index.d.ts +0 -6
  365. package/dist/server/src/api/routes/index.js +0 -32
  366. package/dist/server/src/api/routes/index.js.map +0 -1
  367. package/dist/server/src/api/routes/plugins.routes.d.ts +0 -2
  368. package/dist/server/src/api/routes/plugins.routes.js +0 -363
  369. package/dist/server/src/api/routes/plugins.routes.js.map +0 -1
  370. package/dist/server/src/api/routes/system.routes.d.ts +0 -2
  371. package/dist/server/src/api/routes/system.routes.js +0 -83
  372. package/dist/server/src/api/routes/system.routes.js.map +0 -1
  373. package/dist/server/src/api/routes/users.routes.d.ts +0 -2
  374. package/dist/server/src/api/routes/users.routes.js +0 -139
  375. package/dist/server/src/api/routes/users.routes.js.map +0 -1
  376. package/dist/server/src/api/schemas/backup.schema.d.ts +0 -118
  377. package/dist/server/src/api/schemas/backup.schema.js +0 -75
  378. package/dist/server/src/api/schemas/backup.schema.js.map +0 -1
  379. package/dist/server/src/api/schemas/cameras.schema.d.ts +0 -980
  380. package/dist/server/src/api/schemas/cameras.schema.js +0 -333
  381. package/dist/server/src/api/schemas/cameras.schema.js.map +0 -1
  382. package/dist/server/src/api/schemas/config.schema.d.ts +0 -114
  383. package/dist/server/src/api/schemas/config.schema.js +0 -42
  384. package/dist/server/src/api/schemas/config.schema.js.map +0 -1
  385. package/dist/server/src/api/schemas/go2rtc.schema.d.ts +0 -703
  386. package/dist/server/src/api/schemas/go2rtc.schema.js +0 -180
  387. package/dist/server/src/api/schemas/go2rtc.schema.js.map +0 -1
  388. package/dist/server/src/api/schemas/plugins.schema.d.ts +0 -72
  389. package/dist/server/src/api/schemas/plugins.schema.js +0 -103
  390. package/dist/server/src/api/schemas/plugins.schema.js.map +0 -1
  391. package/dist/server/src/api/schemas/system.schema.d.ts +0 -9
  392. package/dist/server/src/api/schemas/system.schema.js +0 -8
  393. package/dist/server/src/api/schemas/system.schema.js.map +0 -1
  394. package/dist/server/src/api/schemas/users.schema.d.ts +0 -1013
  395. package/dist/server/src/api/schemas/users.schema.js +0 -157
  396. package/dist/server/src/api/schemas/users.schema.js.map +0 -1
  397. package/dist/server/src/api/services/auth.service.d.ts +0 -24
  398. package/dist/server/src/api/services/auth.service.js +0 -191
  399. package/dist/server/src/api/services/auth.service.js.map +0 -1
  400. package/dist/server/src/api/services/backup.service.d.ts +0 -11
  401. package/dist/server/src/api/services/backup.service.js +0 -109
  402. package/dist/server/src/api/services/backup.service.js.map +0 -1
  403. package/dist/server/src/api/services/cameras.service.d.ts +0 -57
  404. package/dist/server/src/api/services/cameras.service.js +0 -790
  405. package/dist/server/src/api/services/cameras.service.js.map +0 -1
  406. package/dist/server/src/api/services/plugins.service.d.ts +0 -26
  407. package/dist/server/src/api/services/plugins.service.js +0 -148
  408. package/dist/server/src/api/services/plugins.service.js.map +0 -1
  409. package/dist/server/src/api/services/system.service.d.ts +0 -7
  410. package/dist/server/src/api/services/system.service.js +0 -23
  411. package/dist/server/src/api/services/system.service.js.map +0 -1
  412. package/dist/server/src/api/services/users.service.d.ts +0 -25
  413. package/dist/server/src/api/services/users.service.js +0 -198
  414. package/dist/server/src/api/services/users.service.js.map +0 -1
  415. package/dist/server/src/api/types/index.d.ts +0 -592
  416. package/dist/server/src/api/types/index.js +0 -9
  417. package/dist/server/src/api/types/index.js.map +0 -1
  418. package/dist/server/src/api/utils/cameraSource.d.ts +0 -2
  419. package/dist/server/src/api/utils/cameraSource.js +0 -34
  420. package/dist/server/src/api/utils/cameraSource.js.map +0 -1
  421. package/dist/server/src/api/utils/cert.d.ts +0 -11
  422. package/dist/server/src/api/utils/cert.js +0 -204
  423. package/dist/server/src/api/utils/cert.js.map +0 -1
  424. package/dist/server/src/api/utils/constants.d.ts +0 -13
  425. package/dist/server/src/api/utils/constants.js +0 -14
  426. package/dist/server/src/api/utils/constants.js.map +0 -1
  427. package/dist/server/src/api/utils/fetch.d.ts +0 -2
  428. package/dist/server/src/api/utils/fetch.js +0 -24
  429. package/dist/server/src/api/utils/fetch.js.map +0 -1
  430. package/dist/server/src/api/utils/moveFiles.d.ts +0 -1
  431. package/dist/server/src/api/utils/moveFiles.js +0 -39
  432. package/dist/server/src/api/utils/moveFiles.js.map +0 -1
  433. package/dist/server/src/api/utils/parse.d.ts +0 -2
  434. package/dist/server/src/api/utils/parse.js +0 -12
  435. package/dist/server/src/api/utils/parse.js.map +0 -1
  436. package/dist/server/src/api/websocket/index.d.ts +0 -16
  437. package/dist/server/src/api/websocket/index.js +0 -76
  438. package/dist/server/src/api/websocket/index.js.map +0 -1
  439. package/dist/server/src/api/websocket/nsp/logs.d.ts +0 -17
  440. package/dist/server/src/api/websocket/nsp/logs.js +0 -151
  441. package/dist/server/src/api/websocket/nsp/logs.js.map +0 -1
  442. package/dist/server/src/api/websocket/nsp/main.d.ts +0 -7
  443. package/dist/server/src/api/websocket/nsp/main.js +0 -8
  444. package/dist/server/src/api/websocket/nsp/main.js.map +0 -1
  445. package/dist/server/src/api/websocket/nsp/metrics.d.ts +0 -24
  446. package/dist/server/src/api/websocket/nsp/metrics.js +0 -169
  447. package/dist/server/src/api/websocket/nsp/metrics.js.map +0 -1
  448. package/dist/server/src/api/websocket/nsp/notifications.d.ts +0 -12
  449. package/dist/server/src/api/websocket/nsp/notifications.js +0 -30
  450. package/dist/server/src/api/websocket/nsp/notifications.js.map +0 -1
  451. package/dist/server/src/api/websocket/nsp/plugins.d.ts +0 -13
  452. package/dist/server/src/api/websocket/nsp/plugins.js +0 -28
  453. package/dist/server/src/api/websocket/nsp/plugins.js.map +0 -1
  454. package/dist/server/src/api/websocket/nsp/server.d.ts +0 -26
  455. package/dist/server/src/api/websocket/nsp/server.js +0 -171
  456. package/dist/server/src/api/websocket/nsp/server.js.map +0 -1
  457. package/dist/server/src/api/websocket/nsp/status.d.ts +0 -15
  458. package/dist/server/src/api/websocket/nsp/status.js +0 -55
  459. package/dist/server/src/api/websocket/nsp/status.js.map +0 -1
  460. package/dist/server/src/api/websocket/types.d.ts +0 -41
  461. package/dist/server/src/api/websocket/types.js +0 -2
  462. package/dist/server/src/api/websocket/types.js.map +0 -1
  463. package/dist/server/src/api.d.ts +0 -28
  464. package/dist/server/src/api.js +0 -109
  465. package/dist/server/src/api.js.map +0 -1
  466. package/dist/server/src/camera/controller.d.ts +0 -62
  467. package/dist/server/src/camera/controller.js +0 -537
  468. package/dist/server/src/camera/controller.js.map +0 -1
  469. package/dist/server/src/camera/frameWorker.d.ts +0 -42
  470. package/dist/server/src/camera/frameWorker.js +0 -305
  471. package/dist/server/src/camera/frameWorker.js.map +0 -1
  472. package/dist/server/src/camera/types.d.ts +0 -11
  473. package/dist/server/src/camera/types.js +0 -2
  474. package/dist/server/src/camera/types.js.map +0 -1
  475. package/dist/server/src/go2rtc/index.d.ts +0 -25
  476. package/dist/server/src/go2rtc/index.js +0 -233
  477. package/dist/server/src/go2rtc/index.js.map +0 -1
  478. package/dist/server/src/go2rtc/types.d.ts +0 -14
  479. package/dist/server/src/go2rtc/types.js +0 -73
  480. package/dist/server/src/go2rtc/types.js.map +0 -1
  481. package/dist/server/src/main.d.ts +0 -2
  482. package/dist/server/src/main.js +0 -112
  483. package/dist/server/src/main.js.map +0 -1
  484. package/dist/server/src/nats/index.d.ts +0 -40
  485. package/dist/server/src/nats/index.js +0 -164
  486. package/dist/server/src/nats/index.js.map +0 -1
  487. package/dist/server/src/nats/proxy/cameraDevice.d.ts +0 -22
  488. package/dist/server/src/nats/proxy/cameraDevice.js +0 -254
  489. package/dist/server/src/nats/proxy/cameraDevice.js.map +0 -1
  490. package/dist/server/src/nats/proxy/coreManager.d.ts +0 -14
  491. package/dist/server/src/nats/proxy/coreManager.js +0 -68
  492. package/dist/server/src/nats/proxy/coreManager.js.map +0 -1
  493. package/dist/server/src/nats/proxy/deviceManager.d.ts +0 -14
  494. package/dist/server/src/nats/proxy/deviceManager.js +0 -101
  495. package/dist/server/src/nats/proxy/deviceManager.js.map +0 -1
  496. package/dist/server/src/nats/server.d.ts +0 -38
  497. package/dist/server/src/nats/server.js +0 -328
  498. package/dist/server/src/nats/server.js.map +0 -1
  499. package/dist/server/src/nats/types.d.ts +0 -18
  500. package/dist/server/src/nats/types.js +0 -2
  501. package/dist/server/src/nats/types.js.map +0 -1
  502. package/dist/server/src/nats/utils.d.ts +0 -2
  503. package/dist/server/src/nats/utils.js +0 -12
  504. package/dist/server/src/nats/utils.js.map +0 -1
  505. package/dist/server/src/nats/websocket.d.ts +0 -27
  506. package/dist/server/src/nats/websocket.js +0 -218
  507. package/dist/server/src/nats/websocket.js.map +0 -1
  508. package/dist/server/src/plugins/index.d.ts +0 -29
  509. package/dist/server/src/plugins/index.js +0 -243
  510. package/dist/server/src/plugins/index.js.map +0 -1
  511. package/dist/server/src/plugins/plugin.d.ts +0 -36
  512. package/dist/server/src/plugins/plugin.js +0 -193
  513. package/dist/server/src/plugins/plugin.js.map +0 -1
  514. package/dist/server/src/plugins/types.d.ts +0 -7
  515. package/dist/server/src/plugins/types.js +0 -3
  516. package/dist/server/src/plugins/types.js.map +0 -1
  517. package/dist/server/src/plugins/worker.d.ts +0 -55
  518. package/dist/server/src/plugins/worker.js +0 -444
  519. package/dist/server/src/plugins/worker.js.map +0 -1
  520. package/dist/server/src/services/config/constants.d.ts +0 -7
  521. package/dist/server/src/services/config/constants.js +0 -67
  522. package/dist/server/src/services/config/constants.js.map +0 -1
  523. package/dist/server/src/services/config/index.d.ts +0 -66
  524. package/dist/server/src/services/config/index.js +0 -462
  525. package/dist/server/src/services/config/index.js.map +0 -1
  526. package/dist/server/src/services/config/types.d.ts +0 -157
  527. package/dist/server/src/services/config/types.js +0 -11
  528. package/dist/server/src/services/config/types.js.map +0 -1
  529. package/dist/server/src/services/logger/index.d.ts +0 -16
  530. package/dist/server/src/services/logger/index.js +0 -67
  531. package/dist/server/src/services/logger/index.js.map +0 -1
  532. package/dist/server/src/types.d.ts +0 -7
  533. package/dist/server/src/types.js +0 -2
  534. package/dist/server/src/types.js.map +0 -1
  535. package/localdeps.txt +0 -6
  536. package/upgrade-server.sh +0 -206
  537. /package/dist/{server/bin/installer → installer}/base.d.ts +0 -0
  538. /package/dist/{server/bin/installer → installer}/base.js +0 -0
  539. /package/dist/{server/bin/installer → installer}/freebsd.d.ts +0 -0
  540. /package/dist/{server/bin/installer → installer}/win32.d.ts +0 -0
  541. /package/dist/{server/bin/logger.d.ts → logger.d.ts} +0 -0
@@ -1,1353 +0,0 @@
1
- import { getNpmPath, orderBy, sleep } from '@camera.ui/common';
2
- import TTLCache from '@isaacs/ttlcache';
3
- import { spawn as spawnPty } from '@scrypted/node-pty';
4
- import AdmZip from 'adm-zip';
5
- import { cyan, green, red, yellow } from 'ansicolor';
6
- import { ensureDir, move, pathExists, readJSON, readJson, remove, writeJson } from 'fs-extra/esm';
7
- import { createHash } from 'node:crypto';
8
- import { constants, createReadStream, readFile as readFileSync, truncate } from 'node:fs';
9
- import { access, mkdtemp, readFile, rmdir, unlink, writeFile } from 'node:fs/promises';
10
- import { platform, tmpdir, userInfo } from 'node:os';
11
- import { basename, dirname, join } from 'node:path';
12
- import { Readable } from 'node:stream';
13
- import { gt, parse as parseVersion, satisfies } from 'semver';
14
- import sharp from 'sharp';
15
- import { x as extract } from 'tar';
16
- import { container } from 'tsyringe';
17
- import { PluginManager } from '../../plugins/index.js';
18
- import { APP_NAME } from '../../services/config/constants.js';
19
- import { ConfigService } from '../../services/config/index.js';
20
- import { CamerasService } from '../services/cameras.service.js';
21
- import { PluginsService } from '../services/plugins.service.js';
22
- import fetchInstance from '../utils/fetch.js';
23
- const npmPluginCache = new TTLCache({ ttl: 300, max: 100 });
24
- const searchResultBlacklist = new Set(['camera.ui', 'homebridge-camera-ui']);
25
- const pluginLogoCache = new TTLCache({ max: 100, ttl: 1000 * 60 * 60 * 24 });
26
- export class PluginsController {
27
- app;
28
- logger;
29
- configService;
30
- io;
31
- pluginManager;
32
- proxyServer;
33
- service;
34
- camerasService;
35
- socketService;
36
- constructor(app) {
37
- this.app = app;
38
- this.io = app.io;
39
- this.service = new PluginsService();
40
- this.camerasService = new CamerasService();
41
- this.logger = container.resolve('logger');
42
- this.configService = container.resolve('configService');
43
- this.pluginManager = container.resolve('pluginManager');
44
- this.proxyServer = container.resolve('proxy');
45
- this.socketService = container.resolve('socketService');
46
- }
47
- async enableByName(req, reply) {
48
- try {
49
- const pluginName = this.resolvePluginName(req.params);
50
- const plugin = this.service.getPluginByName(pluginName);
51
- if (!plugin) {
52
- return reply.code(404).send({
53
- statusCode: 404,
54
- message: 'Plugin not exists',
55
- });
56
- }
57
- if (!plugin.disabled) {
58
- return reply.code(400).send({
59
- statusCode: 404,
60
- message: 'Plugin already enabled',
61
- });
62
- }
63
- plugin.disabled = false;
64
- if (this.configService.config.plugins.disabledPlugins.includes(pluginName)) {
65
- const index = this.configService.config.plugins.disabledPlugins.indexOf(pluginName);
66
- this.configService.config.plugins.disabledPlugins.splice(index, 1);
67
- this.configService.writeConfig();
68
- }
69
- await this.pluginManager.startPluginChild(pluginName);
70
- return reply.code(204).send();
71
- }
72
- catch (error) {
73
- return reply.code(500).send({
74
- statusCode: 500,
75
- message: error.message,
76
- });
77
- }
78
- }
79
- async disableByName(req, reply) {
80
- try {
81
- const pluginName = this.resolvePluginName(req.params);
82
- const plugin = this.service.getPluginByName(pluginName);
83
- if (!plugin) {
84
- return reply.code(404).send({
85
- statusCode: 404,
86
- message: 'Plugin not exists',
87
- });
88
- }
89
- if (plugin.disabled) {
90
- return reply.code(400).send({
91
- statusCode: 404,
92
- message: 'Plugin already disabled',
93
- });
94
- }
95
- plugin.disabled = true;
96
- this.configService.config.plugins.disabledPlugins.push(pluginName);
97
- this.configService.writeConfig();
98
- await this.pluginManager.stopPluginChild(pluginName);
99
- return reply.code(204).send();
100
- }
101
- catch (error) {
102
- return reply.code(500).send({
103
- statusCode: 500,
104
- message: error.message,
105
- });
106
- }
107
- }
108
- getByName(req, reply) {
109
- try {
110
- const pluginName = this.resolvePluginName(req.params);
111
- const plugin = this.service.getPluginByName(pluginName);
112
- if (!plugin) {
113
- return reply.code(404).send({
114
- statusCode: 404,
115
- message: 'Plugin not exists',
116
- });
117
- }
118
- return reply.code(200).send(plugin.info);
119
- }
120
- catch (error) {
121
- return reply.code(500).send({
122
- statusCode: 500,
123
- message: error.message,
124
- });
125
- }
126
- }
127
- async getPluginUpdateByName(req, reply) {
128
- try {
129
- const pluginName = this.resolvePluginName(req.params);
130
- const plugin = this.service.getPluginByName(pluginName);
131
- if (!plugin) {
132
- return reply.code(404).send({
133
- statusCode: 404,
134
- message: 'Plugin not exists',
135
- });
136
- }
137
- const pluginUpdateState = await this.getPluginFromNpm(plugin.info);
138
- return reply.code(200).send(pluginUpdateState);
139
- }
140
- catch (error) {
141
- return reply.code(500).send({
142
- statusCode: 500,
143
- message: error.message,
144
- });
145
- }
146
- }
147
- async getVersionsByName(req, reply) {
148
- try {
149
- const pluginName = this.resolvePluginName(req.params);
150
- const availableVersions = await this.getAvailablePluginVersions(pluginName);
151
- return reply.code(200).send(availableVersions);
152
- }
153
- catch (error) {
154
- return reply.code(500).send({
155
- statusCode: 500,
156
- message: error.message,
157
- });
158
- }
159
- }
160
- async getChangelogByName(req, reply) {
161
- try {
162
- const pluginName = this.resolvePluginName(req.params);
163
- const plugin = this.service.getPluginByName(pluginName);
164
- if (!plugin) {
165
- return reply.code(404).send({
166
- statusCode: 404,
167
- message: 'Plugin not exists',
168
- });
169
- }
170
- try {
171
- const changelog = join(plugin.installPath, 'CHANGELOG.md');
172
- if (await pathExists(changelog)) {
173
- const file = await readFile(`${plugin.installPath}/CHANGELOG.md`, 'utf8');
174
- reply.header('Content-Type', 'text/plain');
175
- return reply.code(200).send(file);
176
- }
177
- }
178
- catch {
179
- //
180
- }
181
- const version = plugin.info.installedVersion ?? 'latest';
182
- const response = await fetchInstance(`https://unpkg.com/${plugin.pluginName}@${version}/CHANGELOG.md`, {
183
- method: 'GET',
184
- });
185
- const data = await response.text();
186
- return reply.code(200).send(data);
187
- }
188
- catch (error) {
189
- return reply.code(500).send({
190
- statusCode: 500,
191
- message: error.message,
192
- });
193
- }
194
- }
195
- async getConfigJsonByName(req, reply) {
196
- try {
197
- const pluginName = this.resolvePluginName(req.params);
198
- const plugin = this.service.getPluginByName(pluginName);
199
- const configFile = plugin?.configFile;
200
- if (!plugin || !configFile) {
201
- return reply.code(404).send({
202
- statusCode: 404,
203
- message: 'Plugin or Plugin Config not exists',
204
- });
205
- }
206
- const config = (await readJSON(configFile, { throws: false })) || {};
207
- reply.header('Content-Type', 'application/json');
208
- return reply.code(200).send(config);
209
- }
210
- catch (error) {
211
- return reply.code(500).send({
212
- statusCode: 500,
213
- message: error.message,
214
- });
215
- }
216
- }
217
- async getPluginLogoByName(req, reply) {
218
- try {
219
- const pluginName = this.resolvePluginName(req.params);
220
- const plugin = this.service.getPluginByName(pluginName);
221
- if (!plugin) {
222
- return reply.code(200).send(Buffer.from('').toString('base64'));
223
- }
224
- const logoPath = join(plugin.installPath, 'logo.png');
225
- if (!(await pathExists(logoPath))) {
226
- return reply.code(200).send(Buffer.from('').toString('base64'));
227
- }
228
- let base64Logo;
229
- pluginLogoCache.purgeStale();
230
- if (pluginLogoCache.has(pluginName)) {
231
- base64Logo = pluginLogoCache.get(pluginName);
232
- }
233
- else {
234
- const logo = await sharp(logoPath).resize({ width: 100, height: 100, fit: 'cover', kernel: 'nearest' }).toBuffer();
235
- base64Logo = Buffer.from(logo).toString('base64');
236
- pluginLogoCache.set(pluginName, base64Logo);
237
- }
238
- reply.header('Content-Type', 'image/png');
239
- return reply.code(200).send(base64Logo);
240
- }
241
- catch (error) {
242
- return reply.code(500).send({
243
- statusCode: 500,
244
- message: error.message,
245
- });
246
- }
247
- }
248
- async getPluginSchemaByName(req, reply) {
249
- try {
250
- const pluginName = this.resolvePluginName(req.params);
251
- const plugin = this.service.getPluginByName(pluginName);
252
- if (!plugin) {
253
- return reply.code(404).send({
254
- statusCode: 404,
255
- message: 'Plugin not exists',
256
- });
257
- }
258
- const schemaPath = join(plugin.installPath, 'config.schema.json');
259
- if (!(await pathExists(schemaPath))) {
260
- return reply.code(200).send();
261
- }
262
- const schemaJson = await readJson(schemaPath, { throws: false });
263
- reply.header('Content-Type', 'application/json');
264
- return reply.code(200).send(schemaJson);
265
- }
266
- catch (error) {
267
- return reply.code(500).send({
268
- statusCode: 500,
269
- message: error.message,
270
- });
271
- }
272
- }
273
- async getPluginInterface(req, reply) {
274
- try {
275
- const pluginName = this.resolvePluginName(req.params);
276
- const plugin = this.service.getPluginByName(pluginName);
277
- if (!plugin) {
278
- return reply.code(404).send({
279
- statusCode: 404,
280
- message: 'Plugin not exists',
281
- });
282
- }
283
- const { type } = req.query.type;
284
- const schemaJson = await this.proxyServer.requestPluginFn(type, plugin.id, 'interfaceSchema', []);
285
- reply.header('Content-Type', 'application/json');
286
- return reply.code(200).send(schemaJson);
287
- }
288
- catch (error) {
289
- return reply.code(500).send({
290
- statusCode: 500,
291
- message: error.message,
292
- });
293
- }
294
- }
295
- async detectObjects(req, reply) {
296
- try {
297
- const pluginName = this.resolvePluginName(req.params);
298
- const plugin = this.service.getPluginByName(pluginName);
299
- if (!plugin) {
300
- return reply.code(404).send({
301
- statusCode: 404,
302
- message: 'Plugin not exists',
303
- });
304
- }
305
- if (!req.isMultipart()) {
306
- throw new Error('No multipart request!');
307
- }
308
- const file = req.body.upload;
309
- const tempDir = await mkdtemp(join(tmpdir(), 'cameraui-object-detection-'));
310
- const fileName = file.filename;
311
- const tempFilePath = join(tempDir, fileName);
312
- const fileBuffer = await file.toBuffer();
313
- await writeFile(tempFilePath, fileBuffer);
314
- const response = await this.proxyServer.requestPluginFn('objectDetection', plugin.id, 'detectObjects', [tempFilePath, req.body.metadata, req.body.config], 15000);
315
- try {
316
- const promises = [];
317
- if (tempFilePath) {
318
- promises.push(unlink(tempFilePath));
319
- }
320
- if (tempDir) {
321
- promises.push(rmdir(tempDir));
322
- }
323
- await Promise.allSettled(promises);
324
- }
325
- catch {
326
- //
327
- }
328
- return reply.code(201).send(response.detections);
329
- }
330
- catch (error) {
331
- return reply.code(500).send({
332
- statusCode: 500,
333
- message: error.message,
334
- });
335
- }
336
- }
337
- async detectAudio(req, reply) {
338
- try {
339
- const pluginName = this.resolvePluginName(req.params);
340
- const plugin = this.service.getPluginByName(pluginName);
341
- if (!plugin) {
342
- return reply.code(404).send({
343
- statusCode: 404,
344
- message: 'Plugin not exists',
345
- });
346
- }
347
- if (!req.isMultipart()) {
348
- throw new Error('No multipart request!');
349
- }
350
- const file = req.body.upload;
351
- const tempDir = await mkdtemp(join(tmpdir(), 'cameraui-audio-detection-'));
352
- const fileName = file.filename;
353
- const tempFilePath = join(tempDir, fileName);
354
- const fileBuffer = await file.toBuffer();
355
- await writeFile(tempFilePath, fileBuffer);
356
- const response = await this.proxyServer.requestPluginFn('audioDetection', plugin.id, 'detectAudio', [tempFilePath, req.body.metadata, req.body.config], 15000);
357
- try {
358
- const promises = [];
359
- if (tempFilePath) {
360
- promises.push(unlink(tempFilePath));
361
- }
362
- if (tempDir) {
363
- promises.push(rmdir(tempDir));
364
- }
365
- await Promise.allSettled(promises);
366
- }
367
- catch {
368
- //
369
- }
370
- return reply.code(201).send(response.detected);
371
- }
372
- catch (error) {
373
- return reply.code(500).send({
374
- statusCode: 500,
375
- message: error.message,
376
- });
377
- }
378
- }
379
- async detectMotion(req, reply) {
380
- try {
381
- const pluginName = this.resolvePluginName(req.params);
382
- const plugin = this.service.getPluginByName(pluginName);
383
- if (!plugin) {
384
- return reply.code(404).send({
385
- statusCode: 404,
386
- message: 'Plugin not exists',
387
- });
388
- }
389
- if (!req.isMultipart()) {
390
- throw new Error('No multipart request!');
391
- }
392
- const file = req.body.upload;
393
- const tempDir = await mkdtemp(join(tmpdir(), 'cameraui-motion-detection-'));
394
- const fileName = file.filename;
395
- const tempFilePath = join(tempDir, fileName);
396
- const fileBuffer = await file.toBuffer();
397
- await writeFile(tempFilePath, fileBuffer);
398
- const response = await this.proxyServer.requestPluginFn('motionDetection', plugin.id, 'detectMotion', [tempFilePath, req.body.config], 60 * 1000);
399
- readFileSync(response.filePath, async (error, fileBuffer) => {
400
- if (error) {
401
- this.logger.error(error);
402
- }
403
- try {
404
- const promises = [];
405
- if (tempFilePath) {
406
- promises.push(unlink(tempFilePath));
407
- }
408
- if (response.filePath && response.filePath !== tempFilePath) {
409
- promises.push(unlink(response.filePath));
410
- }
411
- if (tempDir) {
412
- promises.push(rmdir(tempDir));
413
- }
414
- await Promise.allSettled(promises);
415
- }
416
- catch {
417
- //
418
- }
419
- reply.send(error ?? fileBuffer);
420
- });
421
- reply.header('Content-Type', 'application/octet-stream');
422
- reply.header('Content-Disposition', 'attachment; filename=video.mp4');
423
- return reply;
424
- }
425
- catch (error) {
426
- return reply.code(500).send({
427
- statusCode: 500,
428
- message: error.message,
429
- });
430
- }
431
- }
432
- async submitActionButtonByName(req, reply) {
433
- try {
434
- const pluginName = this.resolvePluginName(req.params);
435
- const plugin = this.service.getPluginByName(pluginName);
436
- const configFile = plugin?.configFile;
437
- if (!plugin || !configFile) {
438
- return reply.code(404).send({
439
- statusCode: 404,
440
- message: 'Plugin or Plugin Config not exists',
441
- });
442
- }
443
- const toastMessage = await this.proxyServer.requestPluginFn('base', plugin.id, 'onFormSubmit', [req.body.actionId, req.body.payload]);
444
- return reply.code(201).send(toastMessage);
445
- }
446
- catch (error) {
447
- return reply.code(500).send({
448
- statusCode: 500,
449
- message: error.message,
450
- });
451
- }
452
- }
453
- getContractByName(req, reply) {
454
- try {
455
- const pluginName = this.resolvePluginName(req.params);
456
- const plugin = this.service.getPluginByName(pluginName);
457
- if (!plugin) {
458
- return reply.code(404).send({
459
- statusCode: 404,
460
- message: 'Plugin not exists',
461
- });
462
- }
463
- const contract = plugin.contract;
464
- const camerasList = plugin.contract.extension || plugin.contract.supportAdditionalCameras ? this.camerasService.list() : this.camerasService.listByPluginId(plugin.id);
465
- const cameras = camerasList?.map((camera) => {
466
- return {
467
- name: camera.name,
468
- extensions: camera.extensions,
469
- };
470
- }) || [];
471
- return reply.code(200).send({ contract, cameras });
472
- }
473
- catch (error) {
474
- return reply.code(500).send({
475
- statusCode: 500,
476
- message: error.message,
477
- });
478
- }
479
- }
480
- async getReadmeByName(req, reply) {
481
- try {
482
- const pluginName = this.resolvePluginName(req.params);
483
- const plugin = this.service.getPluginByName(pluginName);
484
- if (!plugin) {
485
- return reply.code(404).send({
486
- statusCode: 404,
487
- message: 'Plugin not exists',
488
- });
489
- }
490
- try {
491
- const readme = join(plugin.installPath, 'CHANGELOG.md');
492
- if (await pathExists(readme)) {
493
- const file = await readFile(`${plugin.installPath}/README.md`, 'utf8');
494
- reply.header('Content-Type', 'text/plain');
495
- return reply.code(200).send(file);
496
- }
497
- }
498
- catch {
499
- //
500
- }
501
- const version = plugin.info.installedVersion ?? 'latest';
502
- const response = await fetchInstance(`https://unpkg.com/${plugin.pluginName}@${version}/README.md`, {
503
- method: 'GET',
504
- });
505
- const data = await response.text();
506
- return reply.code(200).send(data);
507
- }
508
- catch (error) {
509
- return reply.code(500).send({
510
- statusCode: 500,
511
- message: error.message,
512
- });
513
- }
514
- }
515
- async getReleaseByName(req, reply) {
516
- try {
517
- const pluginName = this.resolvePluginName(req.params);
518
- const plugin = this.service.getPluginByName(pluginName);
519
- if (!plugin) {
520
- return reply.code(404).send({
521
- statusCode: 404,
522
- message: 'Plugin not exists',
523
- });
524
- }
525
- const repoMatch = plugin.info.links?.homepage?.match(/https:\/\/github.com\/([^/]+)\/([^/#]+)/);
526
- if (!repoMatch) {
527
- return reply.code(404).send({
528
- statusCode: 404,
529
- message: '"homepage" not exists in package.json or is not a github repo',
530
- });
531
- }
532
- const response = await fetchInstance(`https://api.github.com/repos/${repoMatch[1]}/${repoMatch[2]}/releases/latest`, {
533
- method: 'GET',
534
- });
535
- const data = await response.json();
536
- return reply.code(200).send({
537
- name: data.name,
538
- changelog: data.body,
539
- });
540
- }
541
- catch (error) {
542
- return reply.code(500).send({
543
- statusCode: 500,
544
- message: error.message,
545
- });
546
- }
547
- }
548
- list(req, reply) {
549
- try {
550
- const installedPlugins = this.service.installedPlugins();
551
- const plugins = installedPlugins.map((plugin) => plugin.info);
552
- return orderBy(plugins, ['displayName'], ['asc']);
553
- // return orderBy(plugins, ['disabled', 'displayName'], ['asc', 'asc']);
554
- }
555
- catch (error) {
556
- return reply.code(500).send({
557
- statusCode: 500,
558
- message: error.message,
559
- });
560
- }
561
- }
562
- listExtensions(req, reply) {
563
- try {
564
- const installedPlugins = this.service.installedPlugins();
565
- const allExtensions = installedPlugins
566
- .filter((plugin) => plugin.contract.extension ?? plugin.contract.supportAdditionalCameras)
567
- .map((plugin) => ({
568
- pluginName: plugin.pluginName,
569
- displayName: plugin.displayName,
570
- type: plugin.contract.extension ? [plugin.contract.extension] : plugin.contract.builtIns,
571
- }));
572
- return orderBy(allExtensions, ['displayName'], ['asc']);
573
- }
574
- catch (error) {
575
- return reply.code(500).send({
576
- statusCode: 500,
577
- message: error.message,
578
- });
579
- }
580
- }
581
- async patchConfigJsonByName(req, reply) {
582
- try {
583
- const pluginName = this.resolvePluginName(req.params);
584
- const plugin = this.service.getPluginByName(pluginName);
585
- const configFile = plugin?.configFile;
586
- if (!plugin || !configFile) {
587
- return reply.code(404).send({
588
- statusCode: 404,
589
- message: 'Plugin or Plugin Config not exists',
590
- });
591
- }
592
- let configData = req.body;
593
- if (typeof req.body === 'string') {
594
- try {
595
- configData = JSON.parse(req.body);
596
- }
597
- catch {
598
- //
599
- }
600
- }
601
- await writeJson(configFile, configData, { spaces: 2 });
602
- return reply.code(201).send(configData);
603
- }
604
- catch (error) {
605
- return reply.code(500).send({
606
- statusCode: 500,
607
- message: error.message,
608
- });
609
- }
610
- }
611
- async restartByName(req, reply) {
612
- try {
613
- const pluginName = this.resolvePluginName(req.params);
614
- const plugin = this.service.getPluginByName(pluginName);
615
- if (!plugin) {
616
- return reply.code(404).send({
617
- statusCode: 404,
618
- message: 'Plugin not exists',
619
- });
620
- }
621
- const pluginProcess = this.service.getPluginProcessByName(pluginName);
622
- if (!pluginProcess) {
623
- return reply.code(404).send({
624
- statusCode: 404,
625
- message: 'Plugin process not initialized',
626
- });
627
- }
628
- await pluginProcess.restart();
629
- return reply.code(204).send();
630
- }
631
- catch (error) {
632
- return reply.code(500).send({
633
- statusCode: 500,
634
- message: error.message,
635
- });
636
- }
637
- }
638
- clearLog(req, reply) {
639
- try {
640
- const pluginName = this.resolvePluginName(req.params);
641
- const plugin = this.service.getPluginByName(pluginName);
642
- if (!plugin) {
643
- return reply.code(404).send({
644
- statusCode: 404,
645
- message: 'Plugin not exists',
646
- });
647
- }
648
- truncate(plugin.logPath, (error) => {
649
- if (error) {
650
- return reply.code(500).send({
651
- statusCode: 500,
652
- message: error.message,
653
- });
654
- }
655
- this.app.io.of('/logs').emit('clear-plugin-log', pluginName);
656
- return reply.code(204).send();
657
- });
658
- }
659
- catch (error) {
660
- return reply.code(500).send({
661
- statusCode: 500,
662
- message: error.message,
663
- });
664
- }
665
- }
666
- downloadLog(req, reply) {
667
- try {
668
- const pluginName = this.resolvePluginName(req.params);
669
- const plugin = this.service.getPluginByName(pluginName);
670
- if (!plugin) {
671
- return reply.code(404).send({
672
- statusCode: 404,
673
- message: 'Plugin not exists',
674
- });
675
- }
676
- const buffer = new Readable();
677
- buffer._read = () => { };
678
- const readStream = createReadStream(plugin.logPath);
679
- readStream.on('data', (data) => {
680
- buffer.push(data.toString('utf8').replace(/\x1b\[[0-9;]*m/g, ''));
681
- });
682
- readStream.on('end', () => {
683
- buffer.push(null);
684
- });
685
- reply.header('Content-Type', 'application/octet-stream');
686
- reply.header('Content-Disposition', `attachment; filename=camera.ui.${plugin.pluginName}.log.txt`);
687
- return reply.code(200).send(buffer);
688
- }
689
- catch (error) {
690
- return reply.code(500).send({
691
- statusCode: 500,
692
- message: error.message,
693
- });
694
- }
695
- }
696
- async search(req, reply) {
697
- try {
698
- const query = req.query.pluginname ?? '';
699
- const q = (!query?.length ? '' : query + '+') + 'keywords:camera-ui-plugin+not:deprecated&size=30';
700
- let searchResults;
701
- try {
702
- const response = await fetchInstance(`https://registry.npmjs.org/-/v1/search?text=${q}`, {
703
- method: 'GET',
704
- });
705
- searchResults = await response.json();
706
- }
707
- catch (error) {
708
- throw new Error(`Failed to search the npm registry - "${error.message}"`);
709
- }
710
- const result = searchResults.objects
711
- .filter((x) => x.package.name.startsWith('camera-ui-') || this.isScopedPlugin(x.package.name))
712
- .filter((x) => !searchResultBlacklist.has(x.package.name))
713
- .map((pkg) => {
714
- let plugin = {
715
- id: '0',
716
- pluginName: pkg.package.name,
717
- displayName: PluginManager.transformDisplaName(pkg.package.name),
718
- private: false,
719
- isPython: false,
720
- isNode: true,
721
- };
722
- const installedPlugins = this.service.installedPlugins();
723
- const isInstalled = installedPlugins.find((installedPlugin) => installedPlugin.pluginName === plugin.pluginName);
724
- if (isInstalled) {
725
- plugin = isInstalled.info;
726
- plugin.lastUpdated = pkg.package.date;
727
- return plugin;
728
- }
729
- plugin.publicPackage = true;
730
- plugin.installedVersion = undefined;
731
- plugin.latestVersion = pkg.package.version;
732
- plugin.lastUpdated = pkg.package.date;
733
- plugin.description = pkg.package.description ? pkg.package.description.replace(/(?:https?|ftp):\/\/[\n\S]+/g, '').trim() : pkg.package.name;
734
- plugin.links = pkg.package.links;
735
- plugin.author = pkg.package.publisher ? pkg.package.publisher.username : undefined;
736
- return plugin;
737
- });
738
- if (!result.length && (query.startsWith('camera-ui-') || this.isScopedPlugin(query)) && !searchResultBlacklist.has(query.toLowerCase())) {
739
- const singlePluginQuey = await this.searchNpmRegistrySingle(query.toLowerCase());
740
- return singlePluginQuey;
741
- }
742
- return orderBy(result, ['displayName'], ['asc']);
743
- }
744
- catch (error) {
745
- return reply.code(500).send({
746
- statusCode: 500,
747
- message: error.message,
748
- });
749
- }
750
- }
751
- async startByName(req, reply) {
752
- try {
753
- const pluginName = this.resolvePluginName(req.params);
754
- const plugin = this.service.getPluginByName(pluginName);
755
- if (!plugin) {
756
- return reply.code(404).send({
757
- statusCode: 404,
758
- message: 'Plugin not exists',
759
- });
760
- }
761
- const pluginProcess = this.service.getPluginProcessByName(pluginName);
762
- if (!pluginProcess) {
763
- return reply.code(404).send({
764
- statusCode: 404,
765
- message: 'Plugin process not initialized',
766
- });
767
- }
768
- await pluginProcess.start();
769
- return reply.code(204).send();
770
- }
771
- catch (error) {
772
- return reply.code(500).send({
773
- statusCode: 500,
774
- message: error.message,
775
- });
776
- }
777
- }
778
- async stopByName(req, reply) {
779
- try {
780
- const pluginName = this.resolvePluginName(req.params);
781
- const plugin = this.service.getPluginByName(pluginName);
782
- if (!plugin) {
783
- return reply.code(404).send({
784
- statusCode: 404,
785
- message: 'Plugin not exists',
786
- });
787
- }
788
- const pluginProcess = this.service.getPluginProcessByName(pluginName);
789
- if (!pluginProcess) {
790
- return reply.code(404).send({
791
- statusCode: 404,
792
- message: 'Plugin process not initialized',
793
- });
794
- }
795
- await pluginProcess.teardown();
796
- return reply.code(204).send();
797
- }
798
- catch (error) {
799
- return reply.code(500).send({
800
- statusCode: 500,
801
- message: error.message,
802
- });
803
- }
804
- }
805
- async installOrUpdate(req, reply) {
806
- try {
807
- let plugin = this.pluginManager.plugins.get(req.body.pluginname);
808
- const command = plugin ? 'update' : 'install';
809
- this.logger.log(`${plugin ? 'Updating' : 'Installing'} plugin: ${req.body.pluginname}@${req.body.pluginversion}`);
810
- const installPath = await this.manage(req.body.pluginname, command, req.body.pluginversion, plugin?.id);
811
- if (!plugin) {
812
- plugin = await this.pluginManager.loadPlugin(installPath);
813
- this.logger.log(`Plugin installed: ${plugin.pluginName}.${plugin.displayName} (${plugin.info.installedVersion})`);
814
- this.pluginManager.initializeInstalledPlugin(plugin);
815
- }
816
- else {
817
- this.logger.log(`Plugin updated: ${plugin.pluginName}.${plugin.displayName} (${req.body.pluginversion}), restarting ...`);
818
- const pluginProcess = this.service.getPluginProcessByName(req.body.pluginname);
819
- pluginProcess?.restart();
820
- }
821
- npmPluginCache.delete(plugin.pluginName);
822
- plugin.reparsePackageJson();
823
- const serverNsp = this.socketService.namespaces.get('/server');
824
- serverNsp.checkPlugins();
825
- return reply.code(201).send(plugin.info);
826
- }
827
- catch (error) {
828
- return reply.code(500).send({
829
- statusCode: 500,
830
- message: error.message,
831
- });
832
- }
833
- }
834
- async updateServer(req, reply) {
835
- try {
836
- this.logger.log(`Updating server: ${APP_NAME}@${req.body.pluginversion}`);
837
- const installPath = await this.manage(APP_NAME, 'installServer', req.body.pluginversion);
838
- this.logger.log(`Server updated: ${APP_NAME}@${ConfigService.VERSION} (${installPath})`);
839
- const serverNsp = this.socketService.namespaces.get('/server');
840
- serverNsp.checkServer();
841
- return reply.code(204).send();
842
- }
843
- catch (error) {
844
- return reply.code(500).send({
845
- statusCode: 500,
846
- message: error.message,
847
- });
848
- }
849
- }
850
- async uninstallByName(req, reply) {
851
- try {
852
- const pluginName = this.resolvePluginName(req.params);
853
- const plugin = this.service.getPluginByName(pluginName);
854
- if (!plugin) {
855
- return reply.code(404).send({
856
- statusCode: 404,
857
- message: 'Plugin not exists',
858
- });
859
- }
860
- this.logger.log(`Uninstalling plugin: ${plugin.pluginName}.${plugin.displayName} (${plugin.info.installedVersion})`);
861
- await this.manage(plugin.pluginName, 'uninstall', undefined, plugin.id);
862
- await this.pluginManager.removePlugin(plugin, req.query.removeStorage);
863
- npmPluginCache.delete(plugin.pluginName);
864
- npmPluginCache.delete(`lookup-${plugin.pluginName}`);
865
- this.logger.log(`Plugin uninstalled: ${plugin.pluginName}.${plugin.displayName} (${plugin.info.installedVersion})`);
866
- return reply.code(204).send();
867
- }
868
- catch (error) {
869
- return reply.code(500).send({
870
- statusCode: 500,
871
- message: error.message,
872
- });
873
- }
874
- }
875
- async uninstallAll(req, reply) {
876
- try {
877
- this.logger.log('Uninstalling all plugins');
878
- const plugins = this.service.installedPlugins();
879
- const pluginNames = plugins.map((plugin) => plugin.pluginName);
880
- await Promise.all(plugins.map((plugin) => this.manage(plugin.pluginName, 'uninstall', undefined, plugin.id)));
881
- for (const plugin of plugins) {
882
- await this.pluginManager.removePlugin(plugin, req.query.removeStorage);
883
- }
884
- const pluginsToDelete = [...pluginNames, ...pluginNames.map((pluginName) => `lookup-${pluginName}`)];
885
- pluginsToDelete.forEach((p) => npmPluginCache.delete(p));
886
- this.logger.log('All plugins uninstalled');
887
- return reply.code(204).send();
888
- }
889
- catch (error) {
890
- return reply.code(500).send({
891
- statusCode: 500,
892
- message: error.message,
893
- });
894
- }
895
- }
896
- async manage(pluginName, action, version, pluginId) {
897
- if (pluginName === APP_NAME && !ConfigService.INSTALL_PATH) {
898
- throw new Error(`Can not determine the install path for ${pluginName}`);
899
- }
900
- const dir = pluginName === APP_NAME ? ConfigService.INSTALL_PATH : this.configService.PLUGINS_INSTALL_PATH;
901
- let targetDir;
902
- if (pluginName === APP_NAME) {
903
- targetDir = dir;
904
- }
905
- else {
906
- targetDir = join(dir, pluginName);
907
- }
908
- this.emitProgress(pluginName, `\r\nUSER: ${userInfo().username}\r\n`, cyan);
909
- this.emitProgress(pluginName, `DIR: ${targetDir}\r\n`, cyan);
910
- this.emitProgress(pluginName, `ACTION: ${action}\r\r\n\n`, cyan);
911
- await this.removeSynologyMetadata();
912
- switch (action) {
913
- case 'install':
914
- await this.installPlugin(pluginName, version ?? 'latest', targetDir);
915
- break;
916
- case 'installServer':
917
- await this.installServer(pluginName, version ?? 'latest', targetDir);
918
- break;
919
- case 'update':
920
- await this.updatePlugin(pluginName, version ?? 'latest', targetDir);
921
- break;
922
- case 'uninstall':
923
- await this.uninstallPlugin(pluginName, targetDir);
924
- await sleep(2000);
925
- break;
926
- default:
927
- throw new Error(`Unknown action: ${action}`);
928
- }
929
- await this.ensurePluginDirExists();
930
- if (pluginId && action === 'uninstall' && pluginName !== APP_NAME) {
931
- await this.camerasService.removeByPluginId(pluginId);
932
- }
933
- return targetDir;
934
- }
935
- async installServer(pluginName, version, targetDir) {
936
- await this.removeSynologyMetadata();
937
- const upgradeInstallScriptPath = join(targetDir, 'upgrade-server.sh');
938
- let timeoutTimer;
939
- const command = [upgradeInstallScriptPath, version, targetDir];
940
- try {
941
- await access(join(targetDir, 'node_modules'), constants.W_OK);
942
- }
943
- catch {
944
- this.emitProgress(pluginName, `The user "${userInfo().username}" does not have write access to the target directory:\r\n\r\n`, yellow);
945
- this.emitProgress(pluginName, `${join(targetDir, 'node_modules')}\r\n\r\n`);
946
- this.emitProgress(pluginName, 'This may cause the operation to fail.\r\n\r\n', yellow);
947
- }
948
- this.logger.log(`Running Command: ${command.join(' ')}`);
949
- if (!satisfies(process.version, `>=${ConfigService.MIN_NODE_VERSION}`)) {
950
- this.emitProgress(pluginName, `Node.js v${ConfigService.MIN_NODE_VERSION} higher is required for ${APP_NAME}.\r\n`, yellow);
951
- this.emitProgress(pluginName, `You may experience issues while running on Node.js ${process.version}.\r\n\r\n`, yellow);
952
- }
953
- // set up the environment for the call
954
- const env = {};
955
- Object.assign(env, process.env);
956
- Object.assign(env, {
957
- // npm_config_install_strategy: 'shallow',
958
- npm_config_unsafe_perm: 'true',
959
- npm_config_update_notifier: 'false',
960
- npm_config_prefer_online: 'true',
961
- npm_config_foreground_scripts: 'true',
962
- npm_config_loglevel: 'info',
963
- npm_config_prefix: targetDir,
964
- });
965
- // set global prefix for unix based systems
966
- if (platform() !== 'win32') {
967
- if (basename(targetDir) === 'lib') {
968
- Object.assign(env, {
969
- npm_config_prefix: dirname(targetDir),
970
- });
971
- }
972
- }
973
- await new Promise((_resolve, _reject) => {
974
- const term = spawnPty(command.shift(), command, {
975
- name: 'xterm-color',
976
- cols: 80,
977
- rows: 30,
978
- cwd: targetDir,
979
- env,
980
- });
981
- // send stdout data from the process to all clients
982
- term.onData((data) => {
983
- this.emitProgress(pluginName, data);
984
- });
985
- // send an error message to the client if the command does not exit with code 0
986
- term.onExit((error) => {
987
- clearTimeout(timeoutTimer);
988
- if (error.exitCode === 0) {
989
- this.emitProgress(pluginName, `\r\nServer ${pluginName}@${version} has been successfully updated.\r\n\r\n`, green);
990
- _resolve(null);
991
- }
992
- else {
993
- this.emitProgress(pluginName, `\r\nError during update of ${pluginName}@${version}.\r\n\r\n`, red);
994
- _reject(new Error('Operation failed. Please review log for details.'));
995
- }
996
- });
997
- // if the command spends to long trying to execute kill it after 5 minutes
998
- timeoutTimer = setTimeout(() => {
999
- term.kill('SIGTERM');
1000
- }, 300000);
1001
- });
1002
- }
1003
- async installPlugin(pluginName, version, targetDir, update) {
1004
- const backupTempDir = join(tmpdir(), `${pluginName}_backup`);
1005
- try {
1006
- const npmRegistry = 'https://registry.npmjs.org';
1007
- const packageUrl = `${npmRegistry}/${pluginName}/${version}`;
1008
- this.emitProgress(pluginName, '> Fetching package information...');
1009
- const response = await fetch(packageUrl);
1010
- if (!response.ok) {
1011
- throw new Error(`HTTP error! status: ${response.status}`);
1012
- }
1013
- const packageInfo = await response.json();
1014
- const tarballUrl = packageInfo.dist.tarball;
1015
- const expectedShasum = packageInfo.dist.shasum;
1016
- this.emitProgress(pluginName, ' Done\r\n\r\n', green);
1017
- const tarballData = await this.downloadWithProgress(tarballUrl, pluginName, version);
1018
- this.emitProgress(pluginName, ' - Done\r\n\r\n', green);
1019
- this.emitProgress(pluginName, '> Verifying package integrity...');
1020
- const computedShasum = createHash('sha1').update(Buffer.from(tarballData)).digest('hex');
1021
- if (computedShasum !== expectedShasum) {
1022
- throw new Error(`SHA checksum mismatch. Expected: ${expectedShasum}, Got: ${computedShasum}`);
1023
- }
1024
- this.emitProgress(pluginName, ' Done\r\n\r\n', green);
1025
- if (await pathExists(targetDir)) {
1026
- this.emitProgress(pluginName, '> Backing up existing installation...');
1027
- await move(targetDir, backupTempDir);
1028
- this.emitProgress(pluginName, ' Done\r\n\r\n', green);
1029
- }
1030
- await ensureDir(targetDir);
1031
- this.emitProgress(pluginName, '> Extracting package...');
1032
- await new Promise((_resolve, _reject) => {
1033
- const extractStream = extract({
1034
- cwd: targetDir,
1035
- strip: 1,
1036
- });
1037
- extractStream.on('error', _reject);
1038
- extractStream.on('end', () => {
1039
- this.emitProgress(pluginName, ' Done\r\n\r\n', green);
1040
- _resolve();
1041
- });
1042
- extractStream.write(Buffer.from(tarballData));
1043
- extractStream.end();
1044
- });
1045
- await this.installProductionDependencies(targetDir, pluginName);
1046
- await this.extrackBundeledPlugin(targetDir, pluginName);
1047
- this.emitProgress(pluginName, '\r\n> Cleaning up...');
1048
- await remove(backupTempDir);
1049
- this.emitProgress(pluginName, ' Done\r\n\r\n', green);
1050
- this.emitProgress(pluginName, `Plugin ${pluginName}@${version} has been successfully ${update ? 'updated' : 'installed'}.\r\n\r\n`, green);
1051
- }
1052
- catch (error) {
1053
- this.emitProgress(pluginName, `\r\nError during ${update ? 'update' : 'installation'} of ${pluginName}@${version}.\r\n\r\n`, red);
1054
- try {
1055
- this.emitProgress(pluginName, '> Restoring previous version...');
1056
- await remove(targetDir);
1057
- await move(backupTempDir, targetDir);
1058
- this.emitProgress(pluginName, ' Done\r\n\r\n', green);
1059
- }
1060
- catch (error) {
1061
- this.emitProgress(pluginName, `\r\n\r\nError: ${error.message}\r\n`, red);
1062
- this.emitProgress(pluginName, 'Failed to restore previous version.\r\n\r\n', red);
1063
- }
1064
- throw error;
1065
- }
1066
- }
1067
- async updatePlugin(pluginName, version, targetDir) {
1068
- try {
1069
- this.emitProgress(pluginName, '> Preparing update...');
1070
- const packageJsonPath = join(targetDir, 'package.json');
1071
- const packageJson = await readJson(packageJsonPath);
1072
- const currentVersion = packageJson.version;
1073
- if (currentVersion === version) {
1074
- this.emitProgress(pluginName, `Plugin ${pluginName} is already up to date.\r\n\r\n`, green);
1075
- return;
1076
- }
1077
- this.emitProgress(pluginName, ' Done\r\n\r\n', green);
1078
- await this.installPlugin(pluginName, version, targetDir, true);
1079
- }
1080
- catch (error) {
1081
- this.emitProgress(pluginName, `\r\nError during update of ${pluginName}@${version}.\r\n\r\n`, red);
1082
- throw error;
1083
- }
1084
- }
1085
- async uninstallPlugin(pluginName, targetDir) {
1086
- try {
1087
- this.emitProgress(pluginName, '> Removing plugin...');
1088
- await remove(targetDir);
1089
- this.emitProgress(pluginName, ' Done\r\n\r\n', green);
1090
- this.emitProgress(pluginName, `Plugin ${pluginName} has been successfully uninstalled.\r\n`, green);
1091
- }
1092
- catch (error) {
1093
- this.emitProgress(pluginName, ' Error\r\n\r\n', red);
1094
- this.emitProgress(pluginName, `\r\nError during uninstallation of ${pluginName}.\r\n\r\n`, red);
1095
- throw error;
1096
- }
1097
- }
1098
- async installProductionDependencies(packageDir, pluginName) {
1099
- await new Promise((_resolve, _reject) => {
1100
- this.emitProgress(pluginName, '> Installing dependencies...\r\n\r\n');
1101
- const command = [...getNpmPath(), 'install', '--omit=dev', '--include=prod', '--loglevel', 'info'];
1102
- const env = {};
1103
- Object.assign(env, process.env);
1104
- Object.assign(env, {
1105
- // npm_config_global_style: 'false',
1106
- // npm_config_install_strategy: 'shallow',
1107
- NODE_ENV: 'production',
1108
- npm_config_unsafe_perm: 'true',
1109
- npm_config_update_notifier: 'false',
1110
- npm_config_prefer_online: 'true',
1111
- // npm_config_foreground_scripts: 'true',
1112
- npm_config_loglevel: 'info',
1113
- npm_config_prefix: packageDir,
1114
- });
1115
- // set global prefix for unix based systems
1116
- if (platform() !== 'win32') {
1117
- if (basename(packageDir) === 'lib') {
1118
- packageDir = dirname(packageDir);
1119
- Object.assign(env, {
1120
- npm_config_prefix: packageDir,
1121
- });
1122
- }
1123
- }
1124
- this.logger.log(`Running Command: ${command.join(' ')}`);
1125
- const term = spawnPty(command.shift(), command, {
1126
- name: 'xterm-color',
1127
- cols: 80,
1128
- rows: 30,
1129
- cwd: packageDir,
1130
- env,
1131
- });
1132
- // send stdout data from the process to all clients
1133
- term.onData((data) => {
1134
- this.emitProgress(pluginName, data);
1135
- });
1136
- // send an error message to the client if the command does not exit with code 0
1137
- term.onExit((error) => {
1138
- clearTimeout(timeoutTimer);
1139
- if (error.exitCode === 0) {
1140
- _resolve(null);
1141
- }
1142
- else {
1143
- _reject(new Error('Operation failed. Please review log for details.'));
1144
- }
1145
- });
1146
- // if the command spends to long trying to execute kill it after 5 minutes
1147
- const timeoutTimer = setTimeout(() => {
1148
- term.kill('SIGTERM');
1149
- }, 300000);
1150
- });
1151
- }
1152
- async extrackBundeledPlugin(packageDir, pluginName) {
1153
- const bundlePath = join(packageDir, 'bundle.zip');
1154
- const isBundeledPlugin = await pathExists(bundlePath);
1155
- if (!isBundeledPlugin) {
1156
- return;
1157
- }
1158
- this.emitProgress(pluginName, '\r\n> Extracting bundled plugin...');
1159
- const zip = new AdmZip(bundlePath);
1160
- zip.extractAllTo(packageDir, true);
1161
- await remove(bundlePath);
1162
- this.emitProgress(pluginName, ' Done', green);
1163
- }
1164
- async ensurePluginDirExists() {
1165
- if (!this.configService.PLUGINS_INSTALL_PATH) {
1166
- return;
1167
- }
1168
- if (!(await pathExists(this.configService.PLUGINS_INSTALL_PATH))) {
1169
- this.logger.warn(`Plugin directory was removed. Re-creating: ${this.configService.PLUGINS_INSTALL_PATH}`);
1170
- try {
1171
- await ensureDir(this.configService.PLUGINS_INSTALL_PATH);
1172
- }
1173
- catch (error) {
1174
- this.logger.error('Failed to recreate plugin directory', error);
1175
- }
1176
- }
1177
- }
1178
- async getAvailablePluginVersions(pluginName) {
1179
- npmPluginCache.purgeStale();
1180
- const fromCache = npmPluginCache.get(`lookup-${pluginName}`);
1181
- let pkg = fromCache;
1182
- if (!pkg) {
1183
- const response = await fetchInstance(`https://registry.npmjs.org/${encodeURIComponent(pluginName).replace(/%40/g, '@')}`, {
1184
- method: 'GET',
1185
- headers: {
1186
- accept: 'application/vnd.npm.install-v1+json', // only return minimal information
1187
- },
1188
- });
1189
- pkg = (await response.json());
1190
- }
1191
- if (!fromCache) {
1192
- npmPluginCache.set(`lookup-${pluginName}`, pkg, { ttl: 60 * 1000 });
1193
- }
1194
- return {
1195
- tags: pkg['dist-tags'],
1196
- versions: Object.keys(pkg.versions).reverse(),
1197
- };
1198
- }
1199
- async getPluginFromNpm(plugin) {
1200
- const pluginState = {
1201
- updateAvailable: false,
1202
- betaUpdateAvailable: false,
1203
- };
1204
- try {
1205
- npmPluginCache.purgeStale();
1206
- // attempt to load from cache
1207
- const fromCache = npmPluginCache.get(plugin.pluginName);
1208
- let pkg = fromCache;
1209
- if (!pkg) {
1210
- const response = await fetchInstance(`https://registry.npmjs.org/${encodeURIComponent(plugin.pluginName).replace(/%40/g, '@')}/latest`, {
1211
- method: 'GET',
1212
- });
1213
- pkg = (await response.json());
1214
- }
1215
- pluginState.latestVersion = pkg.version;
1216
- pluginState.updateAvailable = gt(pkg.version, plugin.installedVersion);
1217
- // check for beta updates, if no latest version is available
1218
- if (!pluginState.updateAvailable) {
1219
- const pluginVersion = parseVersion(plugin.installedVersion);
1220
- if (pluginVersion?.prerelease[0] === 'beta' && gt(plugin.installedVersion, pluginState.latestVersion || '0.0.1')) {
1221
- const versions = await this.getAvailablePluginVersions(plugin.pluginName);
1222
- if (versions.tags.beta && gt(versions.tags.beta, plugin.installedVersion)) {
1223
- pluginState.betaUpdateAvailable = true;
1224
- pluginState.latestVersion = versions.tags.beta;
1225
- }
1226
- }
1227
- }
1228
- // store in cache if it was not there already
1229
- if (!fromCache) {
1230
- npmPluginCache.set(plugin.pluginName, pkg);
1231
- }
1232
- }
1233
- catch (error) {
1234
- if (error.response?.status !== 404) {
1235
- this.logger.error(`[${plugin.pluginName}] Failed to check registry.npmjs.org for updates`, error);
1236
- }
1237
- pluginState.latestVersion = undefined;
1238
- pluginState.updateAvailable = false;
1239
- pluginState.betaUpdateAvailable = false;
1240
- }
1241
- return pluginState;
1242
- }
1243
- async removeSynologyMetadata() {
1244
- if (!this.configService.PLUGINS_INSTALL_PATH) {
1245
- return;
1246
- }
1247
- const offendingPath = join(this.configService.PLUGINS_INSTALL_PATH, '@eaDir');
1248
- try {
1249
- if (!(await pathExists(offendingPath))) {
1250
- await remove(offendingPath);
1251
- }
1252
- }
1253
- catch (error) {
1254
- this.logger.error(`Failed to remove ${offendingPath}`, error);
1255
- }
1256
- }
1257
- async searchNpmRegistrySingle(query) {
1258
- try {
1259
- npmPluginCache.purgeStale();
1260
- const fromCache = npmPluginCache.get(`lookup-${query}`);
1261
- let pkg = fromCache;
1262
- if (!pkg) {
1263
- const response = await fetchInstance(`https://registry.npmjs.org/${encodeURIComponent(query).replace(/%40/g, '@')}`, {
1264
- method: 'GET',
1265
- });
1266
- pkg = (await response.json());
1267
- }
1268
- if (!fromCache) {
1269
- npmPluginCache.set(`lookup-${query}`, pkg, { ttl: 60 * 1000 });
1270
- }
1271
- if (!pkg.keywords?.includes('camera-ui-plugin')) {
1272
- return [];
1273
- }
1274
- let plugin;
1275
- const installedPlugins = this.service.installedPlugins();
1276
- const isInstalled = installedPlugins.find((installedPlugin) => installedPlugin.pluginName === pkg.name);
1277
- if (isInstalled) {
1278
- plugin = isInstalled.info;
1279
- plugin.lastUpdated = pkg.time.modified;
1280
- return [plugin];
1281
- }
1282
- plugin = {
1283
- id: '0',
1284
- pluginName: pkg.name,
1285
- private: false,
1286
- displayName: PluginManager.transformDisplaName(pkg.name),
1287
- description: pkg.description ? pkg.description.replace(/(?:https?|ftp):\/\/[\n\S]+/g, '').trim() : pkg.name,
1288
- isPython: false,
1289
- isNode: true,
1290
- publicPackage: true,
1291
- latestVersion: pkg['dist-tags'] ? pkg['dist-tags'].latest : undefined,
1292
- lastUpdated: pkg.time.modified,
1293
- links: {
1294
- npm: `https://www.npmjs.com/package/${pkg.name}`,
1295
- homepage: pkg.homepage,
1296
- },
1297
- author: pkg.maintainers[0]?.name,
1298
- };
1299
- return [plugin];
1300
- }
1301
- catch (error) {
1302
- if (error.response?.status !== 404) {
1303
- this.logger.error('Failed to search the npm registry', error);
1304
- }
1305
- return [];
1306
- }
1307
- }
1308
- resolvePluginName(params) {
1309
- if (params.scope) {
1310
- const at = params.scope.startsWith('@') ? '' : '@';
1311
- return `${at}${params.scope}/${params.pluginname}`;
1312
- }
1313
- else {
1314
- return params.pluginname;
1315
- }
1316
- }
1317
- isScopedPlugin(pluginName) {
1318
- return pluginName.startsWith('@') && pluginName.split('/').length > 0 && pluginName.split('/')[1]?.startsWith('camera-ui-');
1319
- }
1320
- async downloadWithProgress(url, pluginName, version) {
1321
- const response = await fetch(url);
1322
- if (!response.ok) {
1323
- throw new Error(`HTTP error! status: ${response.status}`);
1324
- }
1325
- const contentLength = Number(response.headers.get('Content-Length'));
1326
- let receivedLength = 0;
1327
- const chunks = [];
1328
- const reader = response.body.getReader();
1329
- this.emitProgress(pluginName, `> Downloading ${pluginName}@${version}...\r\n`);
1330
- while (true) {
1331
- const { done, value } = await reader.read();
1332
- if (done) {
1333
- break;
1334
- }
1335
- chunks.push(value);
1336
- receivedLength += value.length;
1337
- const percentComplete = Math.round((receivedLength / contentLength) * 100);
1338
- const progressBar = this.getProgressBar(percentComplete);
1339
- this.emitProgress(pluginName, `\r${progressBar} ${percentComplete}%`, cyan);
1340
- }
1341
- return await new Blob(chunks).arrayBuffer();
1342
- }
1343
- getProgressBar(percent) {
1344
- const width = 50;
1345
- const complete = Math.round(width * (percent / 100));
1346
- const incomplete = width - complete;
1347
- return `[${'='.repeat(complete)}${'-'.repeat(incomplete)}]`;
1348
- }
1349
- emitProgress(pluginName, message, color) {
1350
- this.io.of('/logs').emit(`stdout/${pluginName}`, color ? color(message) : message);
1351
- }
1352
- }
1353
- //# sourceMappingURL=plugins.controller.js.map