@fde-desktop/fde-core 0.4.7 → 0.4.9

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 (284) hide show
  1. package/dist/AccordionChevron-DxpOyInK.js +26 -0
  2. package/dist/AccordionChevron-kn5kSrEc.cjs +1 -0
  3. package/dist/ActionIcon-Drh4p6Fv.js +145 -0
  4. package/dist/ActionIcon-alk2zZD6.cjs +1 -0
  5. package/dist/AppEmptyState-BWCUbf-B.cjs +1 -0
  6. package/dist/AppEmptyState-Bxpit0JV.js +49 -0
  7. package/dist/AppIcon-BU7a3ZNH.cjs +1 -0
  8. package/dist/AppIcon-XumS3bIG.js +80 -0
  9. package/dist/AppMenuBar-B9U0n1Vv.cjs +1 -0
  10. package/dist/AppMenuBar-CnIEVjr8.js +2049 -0
  11. package/dist/Box-DSKR_qaa.js +1579 -0
  12. package/dist/Box-zW6Twge8.cjs +1 -0
  13. package/dist/Button-DMlnrqyx.cjs +1 -0
  14. package/dist/Button-wTOTQKxF.js +178 -0
  15. package/dist/CalendarApp-B_e1B1Yn.cjs +1 -0
  16. package/dist/CalendarApp-C-l9D6nd.cjs +1 -0
  17. package/dist/CalendarApp-D0ftTCTG.js +1399 -0
  18. package/dist/Center-CmxXB9ql.js +25 -0
  19. package/dist/Center-DKUE2pER.cjs +1 -0
  20. package/dist/CheckIcon-CZhtJD1O.cjs +1 -0
  21. package/dist/CheckIcon-N5qBqXQJ.js +25 -0
  22. package/dist/CodeServerApp-BOoGwZ7r.cjs +1 -0
  23. package/dist/CodeServerApp-Be3I5EGg.cjs +1 -0
  24. package/dist/CodeServerApp-DW18EZxa.js +150 -0
  25. package/dist/ColorPicker-BCNqi02x.js +997 -0
  26. package/dist/ColorPicker-BrDE7tMO.cjs +1 -0
  27. package/dist/Colors-ClnDxnyA.js +15 -0
  28. package/dist/Colors-zP2AFgU3.cjs +1 -0
  29. package/dist/CreateItemApp-B12M1E_1.cjs +1 -0
  30. package/dist/CreateItemApp-TAAprby3.js +400 -0
  31. package/dist/CreateItemApp-ePB6ujNl.cjs +1 -0
  32. package/dist/DeviceInfoApp-BMF18BGo.cjs +1 -0
  33. package/dist/DeviceInfoApp-DRy0H3aT.cjs +1 -0
  34. package/dist/DeviceInfoApp-lgpwkeRR.js +223 -0
  35. package/dist/DownloadProgress-EoyCaD5O.js +174 -0
  36. package/dist/DownloadProgress-VNdj22U8.cjs +1 -0
  37. package/dist/FileIcon-7JaSR3Gn.js +89 -0
  38. package/dist/FileIcon-CIXopWLv.cjs +1 -0
  39. package/dist/FilePickerApp-DaMgEqKh.js +409 -0
  40. package/dist/FilePickerApp-DjmuSFqa.cjs +1 -0
  41. package/dist/FilesApp-Bp7wfrBZ.cjs +1 -0
  42. package/dist/FilesApp-BpJJRKhi.cjs +1 -0
  43. package/dist/FilesApp-Cj94QG5o.js +225 -0
  44. package/dist/Group-CtBJSfCo.js +48 -0
  45. package/dist/Group-Dsrf6lEK.cjs +1 -0
  46. package/dist/ImageViewerApp-BaLP3gkO.js +69 -0
  47. package/dist/ImageViewerApp-DlHGeB3S.cjs +1 -0
  48. package/dist/ImageViewerApp-DoXd_Swu.cjs +1 -0
  49. package/dist/ImageViewerMenuBar-CabGSi9r.js +87 -0
  50. package/dist/ImageViewerMenuBar-SAI7UNz7.cjs +1 -0
  51. package/dist/ImageViewerMenuBar-_Jr29gii.cjs +1 -0
  52. package/dist/MenuEditApp-BJjlPTOa.cjs +1 -0
  53. package/dist/MenuEditApp-BTRppYnD.js +497 -0
  54. package/dist/MenuEditApp-JPsGT-S3.cjs +1 -0
  55. package/dist/MenuEditMenuBar-BydGkqMw.cjs +1 -0
  56. package/dist/MenuEditMenuBar-DptlwVPQ.cjs +1 -0
  57. package/dist/MenuEditMenuBar-x1IQrHP2.js +60 -0
  58. package/dist/NotesApp-BOcRGO7w.cjs +1 -0
  59. package/dist/NotesApp-CQe7UfBC.js +364 -0
  60. package/dist/NotesApp-OL07JXRE.cjs +1 -0
  61. package/dist/NotesMenuBar-BSI_2Y7p.cjs +1 -0
  62. package/dist/NotesMenuBar-Df6aW85J.cjs +1 -0
  63. package/dist/NotesMenuBar-VhpIe68v.js +62 -0
  64. package/dist/Paper-BX_9odR6.js +30 -0
  65. package/dist/Paper-D8-BaBx2.cjs +1 -0
  66. package/dist/PdfApp-CNEbty5v.cjs +1 -0
  67. package/dist/PdfApp-CVv3ZCaM.cjs +1 -0
  68. package/dist/PdfApp-DL_R9-Nc.js +39 -0
  69. package/dist/PdfMenuBar--E6kDyrT.cjs +1 -0
  70. package/dist/PdfMenuBar-DZCLSOpR.js +39 -0
  71. package/dist/PdfMenuBar-Dj5cJUkg.cjs +1 -0
  72. package/dist/SettingsApp-BlmHuAjT.js +1831 -0
  73. package/dist/SettingsApp-CNvIgf5B.cjs +1 -0
  74. package/dist/SettingsApp-DWxanNE4.cjs +1 -0
  75. package/dist/SettingsMenuBar-CBoOBCfx.cjs +1 -0
  76. package/dist/SettingsMenuBar-DQooFkZN.cjs +1 -0
  77. package/dist/SettingsMenuBar-YWiJHaxq.js +42 -0
  78. package/dist/Slider-BUiHxjKO.cjs +1 -0
  79. package/dist/Slider-t-NcD60t.js +1176 -0
  80. package/dist/Stack-Bp1Ek2Gp.js +34 -0
  81. package/dist/Stack-D4jAiRfc.cjs +1 -0
  82. package/dist/StorybookApp-CDLV_kja.cjs +1 -0
  83. package/dist/StorybookApp-DKwlPCmo.js +10 -0
  84. package/dist/TerminalApp-BCB7i1lR.cjs +1 -0
  85. package/dist/TerminalApp-BYc_gHLe.js +326 -0
  86. package/dist/TerminalApp-Dviz6aP2.cjs +1 -0
  87. package/dist/TerminalMenuBar-D5tPmgR_.js +113 -0
  88. package/dist/TerminalMenuBar-DNshPmCa.cjs +1 -0
  89. package/dist/TerminalMenuBar-HzMSR7XP.cjs +1 -0
  90. package/dist/TextInput-C-JtGWn1.js +981 -0
  91. package/dist/TextInput-CrsmcOip.cjs +1 -0
  92. package/dist/Tooltip-D5Cd9wtz.cjs +1 -0
  93. package/dist/Tooltip-DOeIvhrO.js +1142 -0
  94. package/dist/UnstyledButton-DGaG-e_G.js +25 -0
  95. package/dist/UnstyledButton-DX2pTahr.cjs +1 -0
  96. package/dist/UploaderApp-C6xA5Rrf2.cjs +1 -0
  97. package/dist/UploaderApp-DnHIRxB_.cjs +1 -0
  98. package/dist/UploaderApp-qBfpukR_.js +488 -0
  99. package/dist/VscIcon-CcMdrFoJ.cjs +1 -0
  100. package/dist/VscIcon-DBfVnArE.js +8 -0
  101. package/dist/create-safe-context-Bboj0GWC.cjs +1 -0
  102. package/dist/create-safe-context-XT2cxc14.js +12 -0
  103. package/dist/desktopStore-CZoA9VHO.cjs +1 -0
  104. package/dist/desktopStore-F8bgLqFl.js +1768 -0
  105. package/dist/getRuntime-BFK0-8R1.cjs +1 -0
  106. package/dist/getRuntime-DAPqFH2W.js +63 -0
  107. package/dist/imageViewerStore-BB_tssZR.cjs +1 -0
  108. package/dist/imageViewerStore-C5kWz0o7.js +50 -0
  109. package/dist/index.cjs +1 -5642
  110. package/dist/index.css +2 -9192
  111. package/dist/index.d.ts +2258 -2019
  112. package/dist/index.js +4826 -4798
  113. package/dist/is-element-Bu_JY8Qy.js +7 -0
  114. package/dist/is-element-CdV0xajp.cjs +1 -0
  115. package/dist/menuEditStore-CTeM_dns.cjs +1 -0
  116. package/dist/menuEditStore-Cj1zAwxQ.js +38 -0
  117. package/dist/notesStore-BCEl1D_v.cjs +1 -0
  118. package/dist/notesStore-BPyRTHEc.js +36 -0
  119. package/dist/rolldown-runtime-CAFD8bLK.js +11 -0
  120. package/dist/settingsAppStore-BDQ3ts1y.js +29 -0
  121. package/dist/settingsAppStore-CMBc13VU.cjs +1 -0
  122. package/dist/terminalStore-IWdf4Mm6.js +30 -0
  123. package/dist/terminalStore-iIuyodfK.cjs +1 -0
  124. package/dist/use-merged-ref-BT8_u6vW.js +25 -0
  125. package/dist/use-merged-ref-n9Gw9LNn.cjs +1 -0
  126. package/dist/use-resolved-styles-api-8OXE2oRq.cjs +1 -0
  127. package/dist/use-resolved-styles-api-DNUlJJZf.js +21 -0
  128. package/dist/use-uncontrolled-A4hm9ATM.js +23 -0
  129. package/dist/use-uncontrolled-DDJVQiM_.cjs +1 -0
  130. package/dist/useAdaptiveDimensions-AVDc_qPa.js +40 -0
  131. package/dist/useAdaptiveDimensions-CfITBJ_m.cjs +1 -0
  132. package/dist/useCloseInterceptor-BZd3VILp.js +51 -0
  133. package/dist/useCloseInterceptor-yntBEzNc.cjs +1 -0
  134. package/dist/useDynamicIcon-Bf0t2foA.js +22 -0
  135. package/dist/useDynamicIcon-DJ_il30E.cjs +1 -0
  136. package/dist/useMenuBarUtils-nJIPJGIQ.cjs +1 -0
  137. package/dist/useMenuBarUtils-nmu9yehT.js +6 -0
  138. package/dist/useOpenApp-CBIm7Gzl.js +279 -0
  139. package/dist/useOpenApp-DW4x79Zg.cjs +1 -0
  140. package/dist/useResolvedUrl-BkMPM1fM.cjs +1 -0
  141. package/dist/useResolvedUrl-DQpLqOoL.js +30 -0
  142. package/package.json +7 -3
  143. package/dist/CalendarApp-CHLUCAI7.css +0 -744
  144. package/dist/CalendarApp-K7ZOUZ6C.js +0 -2
  145. package/dist/CalendarApp-OTGEERSS.cjs +0 -8
  146. package/dist/CodeServerApp-5KZGO7HL.css +0 -75
  147. package/dist/CodeServerApp-LUZFCQBI.js +0 -3
  148. package/dist/CodeServerApp-P3TMJPLY.cjs +0 -9
  149. package/dist/CreateItemApp-ESQ42VHH.js +0 -8
  150. package/dist/CreateItemApp-PQB5GTFG.css +0 -107
  151. package/dist/CreateItemApp-RFE3REWZ.cjs +0 -14
  152. package/dist/DeviceInfoApp-XNIS6ZY6.js +0 -5
  153. package/dist/DeviceInfoApp-ZNLQNOKI.cjs +0 -11
  154. package/dist/DeviceInfoApp-ZSMRSITP.css +0 -7
  155. package/dist/FilesApp-4GEU64QN.js +0 -8
  156. package/dist/FilesApp-E6L5W3T2.css +0 -1817
  157. package/dist/FilesApp-QSLB5IWR.cjs +0 -14
  158. package/dist/ImageViewerApp-N2Q7E7WZ.css +0 -215
  159. package/dist/ImageViewerApp-NCVDKLB3.js +0 -11
  160. package/dist/ImageViewerApp-QB373H5Z.cjs +0 -17
  161. package/dist/ImageViewerMenuBar-I3TFKQPS.cjs +0 -14
  162. package/dist/ImageViewerMenuBar-TV5C6TM2.js +0 -5
  163. package/dist/ImageViewerMenuBar-XLK4LIHW.css +0 -56
  164. package/dist/MenuEditApp-5EFYAPFC.cjs +0 -15
  165. package/dist/MenuEditApp-V5XOPIHX.js +0 -9
  166. package/dist/MenuEditApp-YA6HSAMJ.css +0 -94
  167. package/dist/MenuEditMenuBar-7VHMZNRM.css +0 -56
  168. package/dist/MenuEditMenuBar-GF6L4PGZ.cjs +0 -15
  169. package/dist/MenuEditMenuBar-IUXFPZE5.js +0 -6
  170. package/dist/NotesApp-2YNT7Y3D.js +0 -10
  171. package/dist/NotesApp-IAEE7YHU.cjs +0 -16
  172. package/dist/NotesApp-TQ6IHDNX.css +0 -302
  173. package/dist/NotesMenuBar-25LKN3SE.cjs +0 -15
  174. package/dist/NotesMenuBar-MXLOX7OT.css +0 -56
  175. package/dist/NotesMenuBar-SRV3AIAL.js +0 -6
  176. package/dist/PdfApp-67XIX6AM.js +0 -10
  177. package/dist/PdfApp-BUIC5U5H.css +0 -206
  178. package/dist/PdfApp-GZ6RHTBR.cjs +0 -16
  179. package/dist/PdfMenuBar-NLZC6JHS.js +0 -4
  180. package/dist/PdfMenuBar-QUM72EE4.css +0 -56
  181. package/dist/PdfMenuBar-WBRTKMLN.cjs +0 -13
  182. package/dist/SettingsApp-BPLMGPNK.cjs +0 -20
  183. package/dist/SettingsApp-JVOSEFH3.css +0 -283
  184. package/dist/SettingsApp-LUDIXCYY.js +0 -14
  185. package/dist/SettingsMenuBar-5CBSSMVM.css +0 -56
  186. package/dist/SettingsMenuBar-VLT6TTCM.js +0 -6
  187. package/dist/SettingsMenuBar-Y5QEXDEO.cjs +0 -15
  188. package/dist/StorybookApp-NQ244BER.css +0 -7
  189. package/dist/StorybookApp-NZDV4X3Y.js +0 -1
  190. package/dist/StorybookApp-VF3KIMU3.cjs +0 -7
  191. package/dist/TerminalApp-CDGWRBFJ.cjs +0 -10
  192. package/dist/TerminalApp-EAATMIMX.css +0 -77
  193. package/dist/TerminalApp-GCKJCM55.js +0 -4
  194. package/dist/TerminalMenuBar-3J26O26Q.css +0 -56
  195. package/dist/TerminalMenuBar-7BH7MGNJ.cjs +0 -14
  196. package/dist/TerminalMenuBar-7JAEQUZ4.js +0 -5
  197. package/dist/UploaderApp-6KV3TGCT.css +0 -1817
  198. package/dist/UploaderApp-FJC2J4I5.js +0 -10
  199. package/dist/UploaderApp-HLXJYJZQ.cjs +0 -16
  200. package/dist/chunk-2PSTHGTD.cjs +0 -42
  201. package/dist/chunk-2RQX7QBP.cjs +0 -148
  202. package/dist/chunk-43W6UDUZ.cjs +0 -19
  203. package/dist/chunk-4E45FBAH.js +0 -223
  204. package/dist/chunk-4E4U2A25.cjs +0 -237
  205. package/dist/chunk-4QHX7CMN.cjs +0 -38
  206. package/dist/chunk-4XURSNM4.js +0 -43
  207. package/dist/chunk-4ZCRYHL6.js +0 -407
  208. package/dist/chunk-5C6IQE42.cjs +0 -35
  209. package/dist/chunk-5HUYQDQF.js +0 -36
  210. package/dist/chunk-5NOHYJNH.js +0 -84
  211. package/dist/chunk-5QFZW6HW.js +0 -2241
  212. package/dist/chunk-5YH6AKEO.js +0 -146
  213. package/dist/chunk-756GPSPM.js +0 -283
  214. package/dist/chunk-7WUYUTPN.js +0 -2293
  215. package/dist/chunk-7XCMBW64.js +0 -162
  216. package/dist/chunk-7Y7HB7FB.cjs +0 -53
  217. package/dist/chunk-ABIAPZ6S.cjs +0 -45
  218. package/dist/chunk-ACHGJKCI.cjs +0 -286
  219. package/dist/chunk-BQCD5RAF.cjs +0 -48
  220. package/dist/chunk-BQL3YXMV.js +0 -17429
  221. package/dist/chunk-C3XER4N3.js +0 -442
  222. package/dist/chunk-C6BEZNAM.cjs +0 -45
  223. package/dist/chunk-CILU6BWC.cjs +0 -548
  224. package/dist/chunk-CV5PUHAE.cjs +0 -86
  225. package/dist/chunk-D5MVFFID.js +0 -42
  226. package/dist/chunk-D7R55WWT.js +0 -1601
  227. package/dist/chunk-DFYDUXWP.cjs +0 -34
  228. package/dist/chunk-DWP2SYF7.js +0 -55
  229. package/dist/chunk-E55VXNLK.cjs +0 -17498
  230. package/dist/chunk-E5FW77FG.js +0 -77
  231. package/dist/chunk-EAELL43F.js +0 -42
  232. package/dist/chunk-EX5V2ZTU.js +0 -40
  233. package/dist/chunk-FD7QZCTN.cjs +0 -2329
  234. package/dist/chunk-FH4ILMKF.js +0 -38
  235. package/dist/chunk-FRHBM2U7.js +0 -33
  236. package/dist/chunk-FX2TPX3L.cjs +0 -45
  237. package/dist/chunk-GPXNLTPI.cjs +0 -451
  238. package/dist/chunk-GRYCUBJZ.js +0 -9
  239. package/dist/chunk-HPHHS7FJ.cjs +0 -49
  240. package/dist/chunk-HWHBSAUC.js +0 -40
  241. package/dist/chunk-IDHP3R4I.js +0 -31
  242. package/dist/chunk-IHWGT3DL.js +0 -86
  243. package/dist/chunk-JEBKLIMU.cjs +0 -123
  244. package/dist/chunk-KDZLBI6F.cjs +0 -324
  245. package/dist/chunk-KQHICFX3.js +0 -121
  246. package/dist/chunk-LMJE6V4N.cjs +0 -42
  247. package/dist/chunk-MCHPDWVH.js +0 -444
  248. package/dist/chunk-MVDGM5Y4.js +0 -68
  249. package/dist/chunk-N36HBL53.cjs +0 -165
  250. package/dist/chunk-NV5GNFA3.js +0 -541
  251. package/dist/chunk-NVEGEK3N.js +0 -31
  252. package/dist/chunk-OJIDKDKF.js +0 -68
  253. package/dist/chunk-PGGNSLM7.js +0 -215
  254. package/dist/chunk-PKPQA5NR.js +0 -15
  255. package/dist/chunk-PNDBLFJW.cjs +0 -50
  256. package/dist/chunk-Q3WA72BF.cjs +0 -70
  257. package/dist/chunk-RDIDAZ3S.cjs +0 -9
  258. package/dist/chunk-RGJPRXYY.js +0 -48
  259. package/dist/chunk-RPSYXORB.cjs +0 -219
  260. package/dist/chunk-RQ6OZRUW.cjs +0 -41
  261. package/dist/chunk-SBE4SZAN.cjs +0 -226
  262. package/dist/chunk-TAFNCDUI.js +0 -234
  263. package/dist/chunk-TFIDSENE.cjs +0 -88
  264. package/dist/chunk-TGWMOHAO.js +0 -17
  265. package/dist/chunk-UA6XSTW6.js +0 -48
  266. package/dist/chunk-UIQCTAVM.cjs +0 -59
  267. package/dist/chunk-UKYESVDS.cjs +0 -50
  268. package/dist/chunk-V4N255NL.cjs +0 -2309
  269. package/dist/chunk-VO6KXO2I.js +0 -32
  270. package/dist/chunk-WXSTSC3D.cjs +0 -83
  271. package/dist/chunk-XSK7BWYO.js +0 -47
  272. package/dist/chunk-XVAPJ4PP.cjs +0 -449
  273. package/dist/chunk-XVASHRCE.cjs +0 -70
  274. package/dist/chunk-XYSMVQQD.cjs +0 -1608
  275. package/dist/chunk-YAIWI4Z5.js +0 -7
  276. package/dist/chunk-YGYOLDKR.js +0 -280
  277. package/dist/chunk-YP2PLNOF.cjs +0 -34
  278. package/dist/chunk-YSOLW4FS.cjs +0 -11
  279. package/dist/chunk-YY6OUR2U.js +0 -44
  280. package/dist/chunk-YZWS7FDT.cjs +0 -409
  281. package/dist/chunk-Z5YGWL65.cjs +0 -39
  282. package/dist/chunk-ZHNDXNL4.js +0 -45
  283. package/dist/chunk-ZX3EDZ5C.cjs +0 -17
  284. package/dist/index.d.cts +0 -2019
@@ -1,31 +0,0 @@
1
- import { create } from 'zustand';
2
-
3
- // src/stores/factories/createWindowStateStore.ts
4
- function createDirtyStateStore() {
5
- const DEFAULT_STATE = { isDirty: false };
6
- return create((set, get) => ({
7
- states: {},
8
- getIsDirty: (windowId) => get().states[windowId]?.isDirty ?? false,
9
- setIsDirty: (windowId, isDirty) => {
10
- const currentIsDirty = get().states[windowId]?.isDirty ?? false;
11
- if (currentIsDirty === isDirty) return;
12
- set((s) => ({
13
- states: {
14
- ...s.states,
15
- [windowId]: { ...s.states[windowId] ?? DEFAULT_STATE, isDirty }
16
- }
17
- }));
18
- },
19
- reset: (windowId) => {
20
- set((s) => ({
21
- states: { ...s.states, [windowId]: DEFAULT_STATE }
22
- }));
23
- }
24
- }));
25
- }
26
-
27
- // src/components/Apps/SettingsApp/settingsAppStore.ts
28
- var useSettingsAppStore = createDirtyStateStore();
29
- var useIsDirty = (windowId) => useSettingsAppStore((s) => s.states[windowId]?.isDirty ?? false);
30
-
31
- export { useIsDirty, useSettingsAppStore };
@@ -1,86 +0,0 @@
1
- import { useImageViewerStore } from './chunk-DWP2SYF7.js';
2
- import { AppEmptyState_default } from './chunk-ZHNDXNL4.js';
3
- import { useResolvedUrl } from './chunk-UA6XSTW6.js';
4
- import { FilePickerModal } from './chunk-MCHPDWVH.js';
5
- import { IMAGE_MIME_TYPES } from './chunk-5QFZW6HW.js';
6
- import { useState, useRef, useEffect, useCallback } from 'react';
7
- import { useTranslation } from 'react-i18next';
8
- import { jsx, jsxs } from 'react/jsx-runtime';
9
-
10
- // src/components/Apps/ImageViewerApp/ImageViewerApp.module.css
11
- var ImageViewerApp_default = {};
12
- var ACCEPTED_IMAGE_TYPES = [...IMAGE_MIME_TYPES, "image/*"];
13
- var ImageViewerApp = ({ window, notifyReady }) => {
14
- const { t } = useTranslation("apps");
15
- const win = window;
16
- const windowId = win?.id ?? "";
17
- const initialSrc = win?.contentData?.src;
18
- const [src, setSrc] = useState(initialSrc);
19
- const [pickerOpen, setPickerOpen] = useState(false);
20
- const [imageDimensions, setImageDimensions] = useState(null);
21
- const containerRef = useRef(null);
22
- const displayZoom = useImageViewerStore((s) => s.getDisplayZoom(windowId));
23
- const fitToWindow = useImageViewerStore((s) => s.getFitToWindow(windowId));
24
- const updateCalculatedZoom = useImageViewerStore((s) => s.updateCalculatedZoom);
25
- const reset = useImageViewerStore((s) => s.reset);
26
- const resolvedSrc = useResolvedUrl(src);
27
- useEffect(() => {
28
- reset(windowId);
29
- }, [windowId, reset]);
30
- useEffect(() => {
31
- if (!fitToWindow || !imageDimensions || !containerRef.current) return;
32
- const observer = new ResizeObserver((entries) => {
33
- for (const entry of entries) {
34
- const { width, height } = entry.contentRect;
35
- updateCalculatedZoom(windowId, imageDimensions, { width, height });
36
- }
37
- });
38
- observer.observe(containerRef.current);
39
- return () => observer.disconnect();
40
- }, [fitToWindow, imageDimensions, windowId, updateCalculatedZoom]);
41
- useEffect(() => {
42
- notifyReady?.({
43
- ...win?.contentData ?? {},
44
- setPickerOpen: () => setPickerOpen(true)
45
- });
46
- }, [win, notifyReady]);
47
- const handleFileSelected = useCallback(
48
- (node) => {
49
- setSrc(node.url ?? node.name);
50
- setPickerOpen(false);
51
- reset(windowId);
52
- setImageDimensions(null);
53
- },
54
- [windowId, reset]
55
- );
56
- const handleImageLoad = useCallback((e) => {
57
- const img = e.currentTarget;
58
- setImageDimensions({ width: img.naturalWidth, height: img.naturalHeight });
59
- }, []);
60
- const imgStyle = fitToWindow ? void 0 : { transform: `scale(${displayZoom / 100})` };
61
- const content = resolvedSrc ? /* @__PURE__ */ jsx(
62
- "img",
63
- {
64
- src: resolvedSrc,
65
- alt: resolvedSrc.split("/").pop() ?? "image",
66
- className: ImageViewerApp_default.image,
67
- style: imgStyle,
68
- onLoad: handleImageLoad
69
- }
70
- ) : /* @__PURE__ */ jsx(AppEmptyState_default, { label: t("imageViewer.noImage") });
71
- return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: ImageViewerApp_default.container, "data-windowid": win?.id, children: [
72
- content,
73
- /* @__PURE__ */ jsx(
74
- FilePickerModal,
75
- {
76
- opened: pickerOpen,
77
- acceptedMimeTypes: ACCEPTED_IMAGE_TYPES,
78
- onConfirm: handleFileSelected,
79
- onCancel: () => setPickerOpen(false)
80
- }
81
- )
82
- ] });
83
- };
84
- var ImageViewerApp_default2 = ImageViewerApp;
85
-
86
- export { ImageViewerApp_default2 as ImageViewerApp_default };
@@ -1,123 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkZ5YGWL65_cjs = require('./chunk-Z5YGWL65.cjs');
4
- var chunkE55VXNLK_cjs = require('./chunk-E55VXNLK.cjs');
5
- var react = require('react');
6
- var fc = require('react-icons/fc');
7
- var reactI18next = require('react-i18next');
8
- var jsxRuntime = require('react/jsx-runtime');
9
-
10
- var CodeServerNotSupported = () => {
11
- const { t } = reactI18next.useTranslation("apps");
12
- return /* @__PURE__ */ jsxRuntime.jsx(chunkE55VXNLK_cjs.Center, { "data-testid": "code-server-not-supported", style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsxs(chunkE55VXNLK_cjs.Stack, { align: "center", gap: "lg", p: "xl", maw: 400, children: [
13
- /* @__PURE__ */ jsxRuntime.jsx(chunkE55VXNLK_cjs.Text, { size: "3rem", children: /* @__PURE__ */ jsxRuntime.jsx(fc.FcInfo, {}) }),
14
- /* @__PURE__ */ jsxRuntime.jsx(chunkE55VXNLK_cjs.Text, { size: "lg", fw: 700, ta: "center", children: t("codeServer.notAvailable") }),
15
- /* @__PURE__ */ jsxRuntime.jsx(chunkE55VXNLK_cjs.Text, { size: "sm", c: "dimmed", ta: "center", children: t("codeServer.notAvailableMessage") }),
16
- /* @__PURE__ */ jsxRuntime.jsx(chunkE55VXNLK_cjs.Text, { size: "sm", c: "dimmed", ta: "center", children: t("codeServer.dockerRequired") })
17
- ] }) });
18
- };
19
-
20
- // src/components/Apps/CodeServerApp/CodeServerApp.module.css
21
- var CodeServerApp_default = {};
22
- var CodeServerAppInner = ({ window, notifyReady }) => {
23
- const win = window;
24
- const [state, setState] = react.useState({
25
- status: "idle",
26
- url: null,
27
- error: null
28
- });
29
- const hasNotifiedRef = react.useRef(false);
30
- const startingRef = react.useRef(false);
31
- const startCodeServer = react.useCallback(async () => {
32
- if (startingRef.current) return;
33
- startingRef.current = true;
34
- setState((prev) => ({ ...prev, status: "starting", error: null }));
35
- try {
36
- const response = await fetch("/api/code-server/start", { method: "POST" });
37
- const data = await response.json();
38
- if (data.success && data.url) {
39
- setState({
40
- status: "running",
41
- url: data.url,
42
- error: null
43
- });
44
- } else {
45
- setState({
46
- status: "error",
47
- url: null,
48
- error: data.error || "Failed to start code-server"
49
- });
50
- }
51
- } catch (err) {
52
- setState({
53
- status: "error",
54
- url: null,
55
- error: err instanceof Error ? err.message : "Failed to start code-server"
56
- });
57
- } finally {
58
- startingRef.current = false;
59
- }
60
- }, []);
61
- const stopCodeServer = react.useCallback(async () => {
62
- try {
63
- await fetch("/api/code-server/stop", { method: "POST" });
64
- } catch (err) {
65
- console.error("[CodeServerApp] Error stopping code-server:", err);
66
- }
67
- }, []);
68
- react.useEffect(() => {
69
- startCodeServer();
70
- return () => {
71
- stopCodeServer();
72
- };
73
- }, [startCodeServer, stopCodeServer]);
74
- react.useEffect(() => {
75
- if (!hasNotifiedRef.current && notifyReady) {
76
- hasNotifiedRef.current = true;
77
- notifyReady({
78
- ...win?.contentData ?? {},
79
- status: state.status,
80
- restart: startCodeServer
81
- });
82
- }
83
- }, [notifyReady, state.status, startCodeServer, win?.contentData]);
84
- react.useEffect(() => {
85
- if (hasNotifiedRef.current && notifyReady) {
86
- notifyReady({
87
- ...win?.contentData ?? {},
88
- status: state.status
89
- });
90
- }
91
- }, [state.status, notifyReady, win?.contentData]);
92
- if (state.status === "idle" || state.status === "starting") {
93
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: CodeServerApp_default.container, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: CodeServerApp_default.loading, children: [
94
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: CodeServerApp_default.spinner }),
95
- /* @__PURE__ */ jsxRuntime.jsx("p", { children: "Starting VS Code..." })
96
- ] }) });
97
- }
98
- if (state.status === "error") {
99
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: CodeServerApp_default.container, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: CodeServerApp_default.error, children: [
100
- /* @__PURE__ */ jsxRuntime.jsx("h3", { children: "Failed to start VS Code" }),
101
- /* @__PURE__ */ jsxRuntime.jsx("p", { children: state.error }),
102
- /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: startCodeServer, className: CodeServerApp_default.retryButton, children: "Retry" })
103
- ] }) });
104
- }
105
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: CodeServerApp_default.container, children: /* @__PURE__ */ jsxRuntime.jsx(
106
- "iframe",
107
- {
108
- src: state.url || "",
109
- className: CodeServerApp_default.iframe,
110
- title: "VS Code",
111
- allow: "clipboard-read; clipboard-write"
112
- }
113
- ) });
114
- };
115
- var CodeServerApp = (props) => {
116
- if (!chunkZ5YGWL65_cjs.isDocker()) {
117
- return /* @__PURE__ */ jsxRuntime.jsx(CodeServerNotSupported, {});
118
- }
119
- return /* @__PURE__ */ jsxRuntime.jsx(CodeServerAppInner, { ...props });
120
- };
121
- var CodeServerApp_default2 = CodeServerApp;
122
-
123
- exports.CodeServerApp_default = CodeServerApp_default2;
@@ -1,324 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk4QHX7CMN_cjs = require('./chunk-4QHX7CMN.cjs');
4
- var chunkV4N255NL_cjs = require('./chunk-V4N255NL.cjs');
5
- var react = require('react');
6
-
7
- // src/constants/Animations.ts
8
- var ANIMATION_DURATION = 0.3;
9
- var createEaseIn = (duration) => ({
10
- duration,
11
- ease: "easeIn"
12
- });
13
- var createEaseOut = (duration) => ({
14
- duration,
15
- ease: "easeOut"
16
- });
17
- var createWindowVariants = (duration) => ({
18
- hidden: { opacity: 0, scale: 0.92, y: 12 },
19
- visible: { opacity: 1, scale: 1, y: 0, transition: createEaseOut(duration) },
20
- exit: { opacity: 0, scale: 0.92, y: 12, transition: createEaseIn(duration) }
21
- });
22
- var createPanelVariants = (duration) => ({
23
- initial: { opacity: 0, y: 8, scale: 0.96 },
24
- animate: { opacity: 1, y: 0, scale: 1, transition: createEaseOut(duration) },
25
- exit: { opacity: 0, y: 8, scale: 0.96, transition: createEaseIn(duration) }
26
- });
27
- var createMinimizeVariant = (duration) => (deltaX, deltaY) => ({
28
- opacity: 0,
29
- scale: 0.1,
30
- x: deltaX,
31
- y: deltaY,
32
- transition: { duration, ease: [0.4, 0, 1, 1] }
33
- });
34
- var createRestoreVariant = (duration) => (deltaX, deltaY) => ({
35
- opacity: [0, 1],
36
- scale: [0.1, 1],
37
- x: [deltaX, 0],
38
- y: [deltaY, 0],
39
- transition: { duration, ease: [0, 0, 0.2, 1] }
40
- });
41
- var createMaximizeTransition = (duration) => ({
42
- duration,
43
- ease: "easeOut"
44
- });
45
- var EASE_IN = { duration: ANIMATION_DURATION, ease: "easeIn" };
46
- var EASE_OUT = { duration: ANIMATION_DURATION, ease: "easeOut" };
47
- var windowVariants = createWindowVariants(ANIMATION_DURATION);
48
- var panelVariants = createPanelVariants(ANIMATION_DURATION);
49
- var minimizeVariant = createMinimizeVariant(0.3);
50
- var restoreVariant = createRestoreVariant(0.3);
51
- var openVariants = {
52
- scale: {
53
- hidden: { opacity: 0, scale: 0.92, y: 12 },
54
- visible: { opacity: 1, scale: 1, y: 0, transition: EASE_OUT }
55
- },
56
- slide: {
57
- hidden: { opacity: 0, y: 40 },
58
- visible: { opacity: 1, y: 0, transition: EASE_OUT }
59
- },
60
- fade: {
61
- hidden: { opacity: 0 },
62
- visible: { opacity: 1, transition: EASE_OUT }
63
- }
64
- };
65
- var maximizeTransition = { duration: 0.25, ease: "easeOut" };
66
- var randomWindowPosition = () => ({
67
- x: 150 + Math.random() * 200,
68
- y: 80 + Math.random() * 100
69
- });
70
- var centerWindowPosition = (viewportWidth, viewportHeight, windowWidth, windowHeight) => ({
71
- x: Math.round((viewportWidth - windowWidth) / 2),
72
- y: Math.round((viewportHeight - windowHeight) / 2)
73
- });
74
- var FilesAppLazy = react.lazy(() => import('./FilesApp-QSLB5IWR.cjs'));
75
- var NotesAppLazy = react.lazy(() => import('./NotesApp-IAEE7YHU.cjs'));
76
- var ImageViewerAppLazy = react.lazy(() => import('./ImageViewerApp-QB373H5Z.cjs'));
77
- var PdfAppLazy = react.lazy(() => import('./PdfApp-GZ6RHTBR.cjs'));
78
- var MenuEditAppLazy = react.lazy(() => import('./MenuEditApp-5EFYAPFC.cjs'));
79
- var UploaderAppLazy = react.lazy(() => import('./UploaderApp-HLXJYJZQ.cjs'));
80
- var SettingsAppLazy = react.lazy(() => import('./SettingsApp-BPLMGPNK.cjs'));
81
- var DeviceInfoAppLazy = react.lazy(() => import('./DeviceInfoApp-ZNLQNOKI.cjs'));
82
- var CalendarAppLazy = react.lazy(() => import('./CalendarApp-OTGEERSS.cjs'));
83
- var CreateItemAppLazy = react.lazy(() => import('./CreateItemApp-RFE3REWZ.cjs'));
84
- var NotesMenuBarLazy = react.lazy(
85
- () => import('./NotesMenuBar-25LKN3SE.cjs').then((m) => ({ default: m.NotesMenuBar }))
86
- );
87
- var MenuEditMenuBarLazy = react.lazy(
88
- () => import('./MenuEditMenuBar-GF6L4PGZ.cjs').then((m) => ({ default: m.MenuEditMenuBar }))
89
- );
90
- var SettingsMenuBarLazy = react.lazy(
91
- () => import('./SettingsMenuBar-Y5QEXDEO.cjs').then((m) => ({ default: m.SettingsMenuBar }))
92
- );
93
- var PdfMenuBarLazy = react.lazy(
94
- () => import('./PdfMenuBar-WBRTKMLN.cjs').then((m) => ({ default: m.PdfMenuBar }))
95
- );
96
- var ImageViewerMenuBarLazy = react.lazy(
97
- () => import('./ImageViewerMenuBar-I3TFKQPS.cjs').then((m) => ({
98
- default: m.ImageViewerMenuBar
99
- }))
100
- );
101
- var TerminalAppLazy = react.lazy(() => import('./TerminalApp-CDGWRBFJ.cjs'));
102
- var TerminalMenuBarLazy = react.lazy(
103
- () => import('./TerminalMenuBar-7BH7MGNJ.cjs').then((m) => ({ default: m.TerminalMenuBar }))
104
- );
105
- var CodeServerAppLazy = react.lazy(() => import('./CodeServerApp-P3TMJPLY.cjs'));
106
- var StorybookAppLazy = react.lazy(() => import('./StorybookApp-VF3KIMU3.cjs'));
107
-
108
- // src/components/Window/helperRegistry.ts
109
- var _registry = null;
110
- var NULL_COMPONENT = (() => null);
111
- function resolveEntry(entry) {
112
- return {
113
- ...entry,
114
- component: entry.component ?? (entry.loader ? react.lazy(entry.loader) : void 0),
115
- MenuBarComponent: entry.MenuBarComponent ?? (entry.menuBarLoader ? react.lazy(entry.menuBarLoader) : void 0)
116
- };
117
- }
118
- function initRegistry(registry) {
119
- _registry = {};
120
- for (const [key, entry] of Object.entries(registry)) {
121
- _registry[key] = resolveEntry(entry);
122
- }
123
- }
124
- function getAppComponent(content) {
125
- if (!_registry) {
126
- console.warn(`[AppRegistry] Registry not initialized, requested app: ${content}`);
127
- return NULL_COMPONENT;
128
- }
129
- const component = _registry[content]?.component;
130
- if (!component) {
131
- console.warn(`[AppRegistry] App not found: ${content}`);
132
- return NULL_COMPONENT;
133
- }
134
- return component;
135
- }
136
- function getMenuBarBuilder(content) {
137
- return _registry?.[content]?.buildMenuBar;
138
- }
139
- function getMenuBarComponent(content) {
140
- return _registry?.[content]?.MenuBarComponent;
141
- }
142
- function isLazyApp(content) {
143
- return _registry?.[content]?.isLazy ?? false;
144
- }
145
- function getAppName(content) {
146
- return _registry?.[content]?.appName;
147
- }
148
- function getRegistryEntry(content) {
149
- return _registry?.[content];
150
- }
151
- function registerComponents(entries) {
152
- if (!_registry) _registry = {};
153
- for (const [key, entry] of Object.entries(entries)) {
154
- _registry[key] = resolveEntry(entry);
155
- }
156
- }
157
- var CORE_REGISTRY = {};
158
- function initCoreRegistry() {
159
- const entries = {
160
- files: {
161
- component: FilesAppLazy,
162
- appName: "Files",
163
- isLazy: true
164
- },
165
- settings: {
166
- component: SettingsAppLazy,
167
- MenuBarComponent: SettingsMenuBarLazy,
168
- appName: "Settings",
169
- isLazy: true
170
- },
171
- pdf: {
172
- component: PdfAppLazy,
173
- MenuBarComponent: PdfMenuBarLazy,
174
- appName: "PDF",
175
- isLazy: true
176
- },
177
- "image-viewer": {
178
- component: ImageViewerAppLazy,
179
- MenuBarComponent: ImageViewerMenuBarLazy,
180
- appName: "Image Viewer",
181
- isLazy: true
182
- },
183
- uploader: {
184
- component: UploaderAppLazy,
185
- appName: "Uploader",
186
- isLazy: true
187
- },
188
- createItem: {
189
- component: CreateItemAppLazy,
190
- appName: "Create Item",
191
- isLazy: true
192
- },
193
- "device-info": {
194
- component: DeviceInfoAppLazy,
195
- appName: "Device Info",
196
- isLazy: true
197
- },
198
- menuedit: {
199
- component: MenuEditAppLazy,
200
- MenuBarComponent: MenuEditMenuBarLazy,
201
- appName: "Menu Editor",
202
- isLazy: true
203
- },
204
- notepad: {
205
- component: NotesAppLazy,
206
- MenuBarComponent: NotesMenuBarLazy,
207
- appName: "Notepad",
208
- isLazy: true
209
- },
210
- calendar: {
211
- component: CalendarAppLazy,
212
- appName: "Calendar",
213
- isLazy: true
214
- },
215
- terminal: {
216
- component: TerminalAppLazy,
217
- MenuBarComponent: TerminalMenuBarLazy,
218
- appName: "Terminal",
219
- isLazy: true
220
- },
221
- "code-server": {
222
- component: CodeServerAppLazy,
223
- appName: "VS Code",
224
- isLazy: true
225
- },
226
- storybook: {
227
- component: StorybookAppLazy,
228
- appName: "Storybook",
229
- isLazy: true
230
- }
231
- };
232
- Object.assign(CORE_REGISTRY, entries);
233
- registerComponents(entries);
234
- }
235
-
236
- // src/hooks/useOpenApp.ts
237
- var useOpenApp = () => {
238
- const openWindow = chunkV4N255NL_cjs.useDesktopStore((state) => state.openWindow);
239
- const focusWindow = chunkV4N255NL_cjs.useDesktopStore((state) => state.focusWindow);
240
- const windows = chunkV4N255NL_cjs.useDesktopStore((state) => state.windows);
241
- const customApps = chunkV4N255NL_cjs.useDesktopStore((state) => state.customApps);
242
- const adaptiveDimensions = chunk4QHX7CMN_cjs.useAdaptiveDimensions();
243
- return react.useCallback(
244
- (appId, { contentData, position } = {}) => {
245
- const app = chunkV4N255NL_cjs.APPS.find((a) => a.id === appId);
246
- const customApp = customApps.find((a) => a.id === appId);
247
- const registryEntry = getRegistryEntry(appId);
248
- const isSingleWindow = app?.singleWindow === true || customApp?.window?.singleWindow === true || registryEntry?.singleWindow === true;
249
- if (isSingleWindow) {
250
- const existingWindow = windows.find((w) => w.content === appId);
251
- if (existingWindow) {
252
- focusWindow(existingWindow.id);
253
- return;
254
- }
255
- }
256
- const { x, y } = position ?? randomWindowPosition();
257
- openWindow({
258
- title: app?.name ?? registryEntry?.appName ?? customApp?.name ?? appId.charAt(0).toUpperCase() + appId.slice(1),
259
- content: appId,
260
- icon: app?.icon ?? registryEntry?.icon ?? customApp?.icon,
261
- fcIcon: app?.fcIcon ?? registryEntry?.fcIcon,
262
- iconUrl: app?.iconUrl ?? registryEntry?.iconUrl,
263
- iconColor: app?.iconColor ?? registryEntry?.iconColor,
264
- canMaximize: app?.canMaximize ?? registryEntry?.canMaximize ?? customApp?.window?.canMaximize,
265
- x,
266
- y,
267
- width: app?.defaultWidth ?? registryEntry?.defaultWidth ?? customApp?.window?.defaultWidth ?? adaptiveDimensions.defaultWidth,
268
- height: app?.defaultHeight ?? registryEntry?.defaultHeight ?? customApp?.window?.defaultHeight ?? adaptiveDimensions.defaultHeight,
269
- minWidth: app?.minWidth === false || registryEntry?.minWidth === false || customApp?.window?.minWidth === false ? void 0 : app?.minWidth ?? registryEntry?.minWidth ?? customApp?.window?.minWidth ?? adaptiveDimensions.minWidth,
270
- minHeight: app?.minHeight === false || registryEntry?.minHeight === false || customApp?.window?.minHeight === false ? void 0 : app?.minHeight ?? registryEntry?.minHeight ?? customApp?.window?.minHeight ?? adaptiveDimensions.minHeight,
271
- contentData: {
272
- ...contentData,
273
- ...app?.autoLoad ? { autoLoad: app.autoLoad } : {}
274
- },
275
- alwaysOnTop: app?.alwaysOnTop ?? registryEntry?.alwaysOnTop
276
- });
277
- },
278
- [openWindow, focusWindow, windows, customApps, adaptiveDimensions]
279
- );
280
- };
281
-
282
- exports.ANIMATION_DURATION = ANIMATION_DURATION;
283
- exports.CORE_REGISTRY = CORE_REGISTRY;
284
- exports.CalendarAppLazy = CalendarAppLazy;
285
- exports.CreateItemAppLazy = CreateItemAppLazy;
286
- exports.DeviceInfoAppLazy = DeviceInfoAppLazy;
287
- exports.EASE_IN = EASE_IN;
288
- exports.EASE_OUT = EASE_OUT;
289
- exports.FilesAppLazy = FilesAppLazy;
290
- exports.ImageViewerAppLazy = ImageViewerAppLazy;
291
- exports.ImageViewerMenuBarLazy = ImageViewerMenuBarLazy;
292
- exports.MenuEditAppLazy = MenuEditAppLazy;
293
- exports.MenuEditMenuBarLazy = MenuEditMenuBarLazy;
294
- exports.NotesAppLazy = NotesAppLazy;
295
- exports.NotesMenuBarLazy = NotesMenuBarLazy;
296
- exports.PdfAppLazy = PdfAppLazy;
297
- exports.PdfMenuBarLazy = PdfMenuBarLazy;
298
- exports.SettingsAppLazy = SettingsAppLazy;
299
- exports.SettingsMenuBarLazy = SettingsMenuBarLazy;
300
- exports.UploaderAppLazy = UploaderAppLazy;
301
- exports.centerWindowPosition = centerWindowPosition;
302
- exports.createEaseIn = createEaseIn;
303
- exports.createEaseOut = createEaseOut;
304
- exports.createMaximizeTransition = createMaximizeTransition;
305
- exports.createMinimizeVariant = createMinimizeVariant;
306
- exports.createPanelVariants = createPanelVariants;
307
- exports.createRestoreVariant = createRestoreVariant;
308
- exports.createWindowVariants = createWindowVariants;
309
- exports.getAppComponent = getAppComponent;
310
- exports.getAppName = getAppName;
311
- exports.getMenuBarBuilder = getMenuBarBuilder;
312
- exports.getMenuBarComponent = getMenuBarComponent;
313
- exports.initCoreRegistry = initCoreRegistry;
314
- exports.initRegistry = initRegistry;
315
- exports.isLazyApp = isLazyApp;
316
- exports.maximizeTransition = maximizeTransition;
317
- exports.minimizeVariant = minimizeVariant;
318
- exports.openVariants = openVariants;
319
- exports.panelVariants = panelVariants;
320
- exports.randomWindowPosition = randomWindowPosition;
321
- exports.registerComponents = registerComponents;
322
- exports.restoreVariant = restoreVariant;
323
- exports.useOpenApp = useOpenApp;
324
- exports.windowVariants = windowVariants;
@@ -1,121 +0,0 @@
1
- import { isDocker } from './chunk-FRHBM2U7.js';
2
- import { Center, Stack, Text } from './chunk-BQL3YXMV.js';
3
- import { useState, useRef, useCallback, useEffect } from 'react';
4
- import { FcInfo } from 'react-icons/fc';
5
- import { useTranslation } from 'react-i18next';
6
- import { jsx, jsxs } from 'react/jsx-runtime';
7
-
8
- var CodeServerNotSupported = () => {
9
- const { t } = useTranslation("apps");
10
- return /* @__PURE__ */ jsx(Center, { "data-testid": "code-server-not-supported", style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ jsxs(Stack, { align: "center", gap: "lg", p: "xl", maw: 400, children: [
11
- /* @__PURE__ */ jsx(Text, { size: "3rem", children: /* @__PURE__ */ jsx(FcInfo, {}) }),
12
- /* @__PURE__ */ jsx(Text, { size: "lg", fw: 700, ta: "center", children: t("codeServer.notAvailable") }),
13
- /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", ta: "center", children: t("codeServer.notAvailableMessage") }),
14
- /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", ta: "center", children: t("codeServer.dockerRequired") })
15
- ] }) });
16
- };
17
-
18
- // src/components/Apps/CodeServerApp/CodeServerApp.module.css
19
- var CodeServerApp_default = {};
20
- var CodeServerAppInner = ({ window, notifyReady }) => {
21
- const win = window;
22
- const [state, setState] = useState({
23
- status: "idle",
24
- url: null,
25
- error: null
26
- });
27
- const hasNotifiedRef = useRef(false);
28
- const startingRef = useRef(false);
29
- const startCodeServer = useCallback(async () => {
30
- if (startingRef.current) return;
31
- startingRef.current = true;
32
- setState((prev) => ({ ...prev, status: "starting", error: null }));
33
- try {
34
- const response = await fetch("/api/code-server/start", { method: "POST" });
35
- const data = await response.json();
36
- if (data.success && data.url) {
37
- setState({
38
- status: "running",
39
- url: data.url,
40
- error: null
41
- });
42
- } else {
43
- setState({
44
- status: "error",
45
- url: null,
46
- error: data.error || "Failed to start code-server"
47
- });
48
- }
49
- } catch (err) {
50
- setState({
51
- status: "error",
52
- url: null,
53
- error: err instanceof Error ? err.message : "Failed to start code-server"
54
- });
55
- } finally {
56
- startingRef.current = false;
57
- }
58
- }, []);
59
- const stopCodeServer = useCallback(async () => {
60
- try {
61
- await fetch("/api/code-server/stop", { method: "POST" });
62
- } catch (err) {
63
- console.error("[CodeServerApp] Error stopping code-server:", err);
64
- }
65
- }, []);
66
- useEffect(() => {
67
- startCodeServer();
68
- return () => {
69
- stopCodeServer();
70
- };
71
- }, [startCodeServer, stopCodeServer]);
72
- useEffect(() => {
73
- if (!hasNotifiedRef.current && notifyReady) {
74
- hasNotifiedRef.current = true;
75
- notifyReady({
76
- ...win?.contentData ?? {},
77
- status: state.status,
78
- restart: startCodeServer
79
- });
80
- }
81
- }, [notifyReady, state.status, startCodeServer, win?.contentData]);
82
- useEffect(() => {
83
- if (hasNotifiedRef.current && notifyReady) {
84
- notifyReady({
85
- ...win?.contentData ?? {},
86
- status: state.status
87
- });
88
- }
89
- }, [state.status, notifyReady, win?.contentData]);
90
- if (state.status === "idle" || state.status === "starting") {
91
- return /* @__PURE__ */ jsx("div", { className: CodeServerApp_default.container, children: /* @__PURE__ */ jsxs("div", { className: CodeServerApp_default.loading, children: [
92
- /* @__PURE__ */ jsx("div", { className: CodeServerApp_default.spinner }),
93
- /* @__PURE__ */ jsx("p", { children: "Starting VS Code..." })
94
- ] }) });
95
- }
96
- if (state.status === "error") {
97
- return /* @__PURE__ */ jsx("div", { className: CodeServerApp_default.container, children: /* @__PURE__ */ jsxs("div", { className: CodeServerApp_default.error, children: [
98
- /* @__PURE__ */ jsx("h3", { children: "Failed to start VS Code" }),
99
- /* @__PURE__ */ jsx("p", { children: state.error }),
100
- /* @__PURE__ */ jsx("button", { onClick: startCodeServer, className: CodeServerApp_default.retryButton, children: "Retry" })
101
- ] }) });
102
- }
103
- return /* @__PURE__ */ jsx("div", { className: CodeServerApp_default.container, children: /* @__PURE__ */ jsx(
104
- "iframe",
105
- {
106
- src: state.url || "",
107
- className: CodeServerApp_default.iframe,
108
- title: "VS Code",
109
- allow: "clipboard-read; clipboard-write"
110
- }
111
- ) });
112
- };
113
- var CodeServerApp = (props) => {
114
- if (!isDocker()) {
115
- return /* @__PURE__ */ jsx(CodeServerNotSupported, {});
116
- }
117
- return /* @__PURE__ */ jsx(CodeServerAppInner, { ...props });
118
- };
119
- var CodeServerApp_default2 = CodeServerApp;
120
-
121
- export { CodeServerApp_default2 as CodeServerApp_default };