@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.
- package/dist/AccordionChevron-DxpOyInK.js +26 -0
- package/dist/AccordionChevron-kn5kSrEc.cjs +1 -0
- package/dist/ActionIcon-Drh4p6Fv.js +145 -0
- package/dist/ActionIcon-alk2zZD6.cjs +1 -0
- package/dist/AppEmptyState-BWCUbf-B.cjs +1 -0
- package/dist/AppEmptyState-Bxpit0JV.js +49 -0
- package/dist/AppIcon-BU7a3ZNH.cjs +1 -0
- package/dist/AppIcon-XumS3bIG.js +80 -0
- package/dist/AppMenuBar-B9U0n1Vv.cjs +1 -0
- package/dist/AppMenuBar-CnIEVjr8.js +2049 -0
- package/dist/Box-DSKR_qaa.js +1579 -0
- package/dist/Box-zW6Twge8.cjs +1 -0
- package/dist/Button-DMlnrqyx.cjs +1 -0
- package/dist/Button-wTOTQKxF.js +178 -0
- package/dist/CalendarApp-B_e1B1Yn.cjs +1 -0
- package/dist/CalendarApp-C-l9D6nd.cjs +1 -0
- package/dist/CalendarApp-D0ftTCTG.js +1399 -0
- package/dist/Center-CmxXB9ql.js +25 -0
- package/dist/Center-DKUE2pER.cjs +1 -0
- package/dist/CheckIcon-CZhtJD1O.cjs +1 -0
- package/dist/CheckIcon-N5qBqXQJ.js +25 -0
- package/dist/CodeServerApp-BOoGwZ7r.cjs +1 -0
- package/dist/CodeServerApp-Be3I5EGg.cjs +1 -0
- package/dist/CodeServerApp-DW18EZxa.js +150 -0
- package/dist/ColorPicker-BCNqi02x.js +997 -0
- package/dist/ColorPicker-BrDE7tMO.cjs +1 -0
- package/dist/Colors-ClnDxnyA.js +15 -0
- package/dist/Colors-zP2AFgU3.cjs +1 -0
- package/dist/CreateItemApp-B12M1E_1.cjs +1 -0
- package/dist/CreateItemApp-TAAprby3.js +400 -0
- package/dist/CreateItemApp-ePB6ujNl.cjs +1 -0
- package/dist/DeviceInfoApp-BMF18BGo.cjs +1 -0
- package/dist/DeviceInfoApp-DRy0H3aT.cjs +1 -0
- package/dist/DeviceInfoApp-lgpwkeRR.js +223 -0
- package/dist/DownloadProgress-EoyCaD5O.js +174 -0
- package/dist/DownloadProgress-VNdj22U8.cjs +1 -0
- package/dist/FileIcon-7JaSR3Gn.js +89 -0
- package/dist/FileIcon-CIXopWLv.cjs +1 -0
- package/dist/FilePickerApp-DaMgEqKh.js +409 -0
- package/dist/FilePickerApp-DjmuSFqa.cjs +1 -0
- package/dist/FilesApp-Bp7wfrBZ.cjs +1 -0
- package/dist/FilesApp-BpJJRKhi.cjs +1 -0
- package/dist/FilesApp-Cj94QG5o.js +225 -0
- package/dist/Group-CtBJSfCo.js +48 -0
- package/dist/Group-Dsrf6lEK.cjs +1 -0
- package/dist/ImageViewerApp-BaLP3gkO.js +69 -0
- package/dist/ImageViewerApp-DlHGeB3S.cjs +1 -0
- package/dist/ImageViewerApp-DoXd_Swu.cjs +1 -0
- package/dist/ImageViewerMenuBar-CabGSi9r.js +87 -0
- package/dist/ImageViewerMenuBar-SAI7UNz7.cjs +1 -0
- package/dist/ImageViewerMenuBar-_Jr29gii.cjs +1 -0
- package/dist/MenuEditApp-BJjlPTOa.cjs +1 -0
- package/dist/MenuEditApp-BTRppYnD.js +497 -0
- package/dist/MenuEditApp-JPsGT-S3.cjs +1 -0
- package/dist/MenuEditMenuBar-BydGkqMw.cjs +1 -0
- package/dist/MenuEditMenuBar-DptlwVPQ.cjs +1 -0
- package/dist/MenuEditMenuBar-x1IQrHP2.js +60 -0
- package/dist/NotesApp-BOcRGO7w.cjs +1 -0
- package/dist/NotesApp-CQe7UfBC.js +364 -0
- package/dist/NotesApp-OL07JXRE.cjs +1 -0
- package/dist/NotesMenuBar-BSI_2Y7p.cjs +1 -0
- package/dist/NotesMenuBar-Df6aW85J.cjs +1 -0
- package/dist/NotesMenuBar-VhpIe68v.js +62 -0
- package/dist/Paper-BX_9odR6.js +30 -0
- package/dist/Paper-D8-BaBx2.cjs +1 -0
- package/dist/PdfApp-CNEbty5v.cjs +1 -0
- package/dist/PdfApp-CVv3ZCaM.cjs +1 -0
- package/dist/PdfApp-DL_R9-Nc.js +39 -0
- package/dist/PdfMenuBar--E6kDyrT.cjs +1 -0
- package/dist/PdfMenuBar-DZCLSOpR.js +39 -0
- package/dist/PdfMenuBar-Dj5cJUkg.cjs +1 -0
- package/dist/SettingsApp-BlmHuAjT.js +1831 -0
- package/dist/SettingsApp-CNvIgf5B.cjs +1 -0
- package/dist/SettingsApp-DWxanNE4.cjs +1 -0
- package/dist/SettingsMenuBar-CBoOBCfx.cjs +1 -0
- package/dist/SettingsMenuBar-DQooFkZN.cjs +1 -0
- package/dist/SettingsMenuBar-YWiJHaxq.js +42 -0
- package/dist/Slider-BUiHxjKO.cjs +1 -0
- package/dist/Slider-t-NcD60t.js +1176 -0
- package/dist/Stack-Bp1Ek2Gp.js +34 -0
- package/dist/Stack-D4jAiRfc.cjs +1 -0
- package/dist/StorybookApp-CDLV_kja.cjs +1 -0
- package/dist/StorybookApp-DKwlPCmo.js +10 -0
- package/dist/TerminalApp-BCB7i1lR.cjs +1 -0
- package/dist/TerminalApp-BYc_gHLe.js +326 -0
- package/dist/TerminalApp-Dviz6aP2.cjs +1 -0
- package/dist/TerminalMenuBar-D5tPmgR_.js +113 -0
- package/dist/TerminalMenuBar-DNshPmCa.cjs +1 -0
- package/dist/TerminalMenuBar-HzMSR7XP.cjs +1 -0
- package/dist/TextInput-C-JtGWn1.js +981 -0
- package/dist/TextInput-CrsmcOip.cjs +1 -0
- package/dist/Tooltip-D5Cd9wtz.cjs +1 -0
- package/dist/Tooltip-DOeIvhrO.js +1142 -0
- package/dist/UnstyledButton-DGaG-e_G.js +25 -0
- package/dist/UnstyledButton-DX2pTahr.cjs +1 -0
- package/dist/UploaderApp-C6xA5Rrf2.cjs +1 -0
- package/dist/UploaderApp-DnHIRxB_.cjs +1 -0
- package/dist/UploaderApp-qBfpukR_.js +488 -0
- package/dist/VscIcon-CcMdrFoJ.cjs +1 -0
- package/dist/VscIcon-DBfVnArE.js +8 -0
- package/dist/create-safe-context-Bboj0GWC.cjs +1 -0
- package/dist/create-safe-context-XT2cxc14.js +12 -0
- package/dist/desktopStore-CZoA9VHO.cjs +1 -0
- package/dist/desktopStore-F8bgLqFl.js +1768 -0
- package/dist/getRuntime-BFK0-8R1.cjs +1 -0
- package/dist/getRuntime-DAPqFH2W.js +63 -0
- package/dist/imageViewerStore-BB_tssZR.cjs +1 -0
- package/dist/imageViewerStore-C5kWz0o7.js +50 -0
- package/dist/index.cjs +1 -5642
- package/dist/index.css +2 -9192
- package/dist/index.d.ts +2258 -2019
- package/dist/index.js +4826 -4798
- package/dist/is-element-Bu_JY8Qy.js +7 -0
- package/dist/is-element-CdV0xajp.cjs +1 -0
- package/dist/menuEditStore-CTeM_dns.cjs +1 -0
- package/dist/menuEditStore-Cj1zAwxQ.js +38 -0
- package/dist/notesStore-BCEl1D_v.cjs +1 -0
- package/dist/notesStore-BPyRTHEc.js +36 -0
- package/dist/rolldown-runtime-CAFD8bLK.js +11 -0
- package/dist/settingsAppStore-BDQ3ts1y.js +29 -0
- package/dist/settingsAppStore-CMBc13VU.cjs +1 -0
- package/dist/terminalStore-IWdf4Mm6.js +30 -0
- package/dist/terminalStore-iIuyodfK.cjs +1 -0
- package/dist/use-merged-ref-BT8_u6vW.js +25 -0
- package/dist/use-merged-ref-n9Gw9LNn.cjs +1 -0
- package/dist/use-resolved-styles-api-8OXE2oRq.cjs +1 -0
- package/dist/use-resolved-styles-api-DNUlJJZf.js +21 -0
- package/dist/use-uncontrolled-A4hm9ATM.js +23 -0
- package/dist/use-uncontrolled-DDJVQiM_.cjs +1 -0
- package/dist/useAdaptiveDimensions-AVDc_qPa.js +40 -0
- package/dist/useAdaptiveDimensions-CfITBJ_m.cjs +1 -0
- package/dist/useCloseInterceptor-BZd3VILp.js +51 -0
- package/dist/useCloseInterceptor-yntBEzNc.cjs +1 -0
- package/dist/useDynamicIcon-Bf0t2foA.js +22 -0
- package/dist/useDynamicIcon-DJ_il30E.cjs +1 -0
- package/dist/useMenuBarUtils-nJIPJGIQ.cjs +1 -0
- package/dist/useMenuBarUtils-nmu9yehT.js +6 -0
- package/dist/useOpenApp-CBIm7Gzl.js +279 -0
- package/dist/useOpenApp-DW4x79Zg.cjs +1 -0
- package/dist/useResolvedUrl-BkMPM1fM.cjs +1 -0
- package/dist/useResolvedUrl-DQpLqOoL.js +30 -0
- package/package.json +7 -3
- package/dist/CalendarApp-CHLUCAI7.css +0 -744
- package/dist/CalendarApp-K7ZOUZ6C.js +0 -2
- package/dist/CalendarApp-OTGEERSS.cjs +0 -8
- package/dist/CodeServerApp-5KZGO7HL.css +0 -75
- package/dist/CodeServerApp-LUZFCQBI.js +0 -3
- package/dist/CodeServerApp-P3TMJPLY.cjs +0 -9
- package/dist/CreateItemApp-ESQ42VHH.js +0 -8
- package/dist/CreateItemApp-PQB5GTFG.css +0 -107
- package/dist/CreateItemApp-RFE3REWZ.cjs +0 -14
- package/dist/DeviceInfoApp-XNIS6ZY6.js +0 -5
- package/dist/DeviceInfoApp-ZNLQNOKI.cjs +0 -11
- package/dist/DeviceInfoApp-ZSMRSITP.css +0 -7
- package/dist/FilesApp-4GEU64QN.js +0 -8
- package/dist/FilesApp-E6L5W3T2.css +0 -1817
- package/dist/FilesApp-QSLB5IWR.cjs +0 -14
- package/dist/ImageViewerApp-N2Q7E7WZ.css +0 -215
- package/dist/ImageViewerApp-NCVDKLB3.js +0 -11
- package/dist/ImageViewerApp-QB373H5Z.cjs +0 -17
- package/dist/ImageViewerMenuBar-I3TFKQPS.cjs +0 -14
- package/dist/ImageViewerMenuBar-TV5C6TM2.js +0 -5
- package/dist/ImageViewerMenuBar-XLK4LIHW.css +0 -56
- package/dist/MenuEditApp-5EFYAPFC.cjs +0 -15
- package/dist/MenuEditApp-V5XOPIHX.js +0 -9
- package/dist/MenuEditApp-YA6HSAMJ.css +0 -94
- package/dist/MenuEditMenuBar-7VHMZNRM.css +0 -56
- package/dist/MenuEditMenuBar-GF6L4PGZ.cjs +0 -15
- package/dist/MenuEditMenuBar-IUXFPZE5.js +0 -6
- package/dist/NotesApp-2YNT7Y3D.js +0 -10
- package/dist/NotesApp-IAEE7YHU.cjs +0 -16
- package/dist/NotesApp-TQ6IHDNX.css +0 -302
- package/dist/NotesMenuBar-25LKN3SE.cjs +0 -15
- package/dist/NotesMenuBar-MXLOX7OT.css +0 -56
- package/dist/NotesMenuBar-SRV3AIAL.js +0 -6
- package/dist/PdfApp-67XIX6AM.js +0 -10
- package/dist/PdfApp-BUIC5U5H.css +0 -206
- package/dist/PdfApp-GZ6RHTBR.cjs +0 -16
- package/dist/PdfMenuBar-NLZC6JHS.js +0 -4
- package/dist/PdfMenuBar-QUM72EE4.css +0 -56
- package/dist/PdfMenuBar-WBRTKMLN.cjs +0 -13
- package/dist/SettingsApp-BPLMGPNK.cjs +0 -20
- package/dist/SettingsApp-JVOSEFH3.css +0 -283
- package/dist/SettingsApp-LUDIXCYY.js +0 -14
- package/dist/SettingsMenuBar-5CBSSMVM.css +0 -56
- package/dist/SettingsMenuBar-VLT6TTCM.js +0 -6
- package/dist/SettingsMenuBar-Y5QEXDEO.cjs +0 -15
- package/dist/StorybookApp-NQ244BER.css +0 -7
- package/dist/StorybookApp-NZDV4X3Y.js +0 -1
- package/dist/StorybookApp-VF3KIMU3.cjs +0 -7
- package/dist/TerminalApp-CDGWRBFJ.cjs +0 -10
- package/dist/TerminalApp-EAATMIMX.css +0 -77
- package/dist/TerminalApp-GCKJCM55.js +0 -4
- package/dist/TerminalMenuBar-3J26O26Q.css +0 -56
- package/dist/TerminalMenuBar-7BH7MGNJ.cjs +0 -14
- package/dist/TerminalMenuBar-7JAEQUZ4.js +0 -5
- package/dist/UploaderApp-6KV3TGCT.css +0 -1817
- package/dist/UploaderApp-FJC2J4I5.js +0 -10
- package/dist/UploaderApp-HLXJYJZQ.cjs +0 -16
- package/dist/chunk-2PSTHGTD.cjs +0 -42
- package/dist/chunk-2RQX7QBP.cjs +0 -148
- package/dist/chunk-43W6UDUZ.cjs +0 -19
- package/dist/chunk-4E45FBAH.js +0 -223
- package/dist/chunk-4E4U2A25.cjs +0 -237
- package/dist/chunk-4QHX7CMN.cjs +0 -38
- package/dist/chunk-4XURSNM4.js +0 -43
- package/dist/chunk-4ZCRYHL6.js +0 -407
- package/dist/chunk-5C6IQE42.cjs +0 -35
- package/dist/chunk-5HUYQDQF.js +0 -36
- package/dist/chunk-5NOHYJNH.js +0 -84
- package/dist/chunk-5QFZW6HW.js +0 -2241
- package/dist/chunk-5YH6AKEO.js +0 -146
- package/dist/chunk-756GPSPM.js +0 -283
- package/dist/chunk-7WUYUTPN.js +0 -2293
- package/dist/chunk-7XCMBW64.js +0 -162
- package/dist/chunk-7Y7HB7FB.cjs +0 -53
- package/dist/chunk-ABIAPZ6S.cjs +0 -45
- package/dist/chunk-ACHGJKCI.cjs +0 -286
- package/dist/chunk-BQCD5RAF.cjs +0 -48
- package/dist/chunk-BQL3YXMV.js +0 -17429
- package/dist/chunk-C3XER4N3.js +0 -442
- package/dist/chunk-C6BEZNAM.cjs +0 -45
- package/dist/chunk-CILU6BWC.cjs +0 -548
- package/dist/chunk-CV5PUHAE.cjs +0 -86
- package/dist/chunk-D5MVFFID.js +0 -42
- package/dist/chunk-D7R55WWT.js +0 -1601
- package/dist/chunk-DFYDUXWP.cjs +0 -34
- package/dist/chunk-DWP2SYF7.js +0 -55
- package/dist/chunk-E55VXNLK.cjs +0 -17498
- package/dist/chunk-E5FW77FG.js +0 -77
- package/dist/chunk-EAELL43F.js +0 -42
- package/dist/chunk-EX5V2ZTU.js +0 -40
- package/dist/chunk-FD7QZCTN.cjs +0 -2329
- package/dist/chunk-FH4ILMKF.js +0 -38
- package/dist/chunk-FRHBM2U7.js +0 -33
- package/dist/chunk-FX2TPX3L.cjs +0 -45
- package/dist/chunk-GPXNLTPI.cjs +0 -451
- package/dist/chunk-GRYCUBJZ.js +0 -9
- package/dist/chunk-HPHHS7FJ.cjs +0 -49
- package/dist/chunk-HWHBSAUC.js +0 -40
- package/dist/chunk-IDHP3R4I.js +0 -31
- package/dist/chunk-IHWGT3DL.js +0 -86
- package/dist/chunk-JEBKLIMU.cjs +0 -123
- package/dist/chunk-KDZLBI6F.cjs +0 -324
- package/dist/chunk-KQHICFX3.js +0 -121
- package/dist/chunk-LMJE6V4N.cjs +0 -42
- package/dist/chunk-MCHPDWVH.js +0 -444
- package/dist/chunk-MVDGM5Y4.js +0 -68
- package/dist/chunk-N36HBL53.cjs +0 -165
- package/dist/chunk-NV5GNFA3.js +0 -541
- package/dist/chunk-NVEGEK3N.js +0 -31
- package/dist/chunk-OJIDKDKF.js +0 -68
- package/dist/chunk-PGGNSLM7.js +0 -215
- package/dist/chunk-PKPQA5NR.js +0 -15
- package/dist/chunk-PNDBLFJW.cjs +0 -50
- package/dist/chunk-Q3WA72BF.cjs +0 -70
- package/dist/chunk-RDIDAZ3S.cjs +0 -9
- package/dist/chunk-RGJPRXYY.js +0 -48
- package/dist/chunk-RPSYXORB.cjs +0 -219
- package/dist/chunk-RQ6OZRUW.cjs +0 -41
- package/dist/chunk-SBE4SZAN.cjs +0 -226
- package/dist/chunk-TAFNCDUI.js +0 -234
- package/dist/chunk-TFIDSENE.cjs +0 -88
- package/dist/chunk-TGWMOHAO.js +0 -17
- package/dist/chunk-UA6XSTW6.js +0 -48
- package/dist/chunk-UIQCTAVM.cjs +0 -59
- package/dist/chunk-UKYESVDS.cjs +0 -50
- package/dist/chunk-V4N255NL.cjs +0 -2309
- package/dist/chunk-VO6KXO2I.js +0 -32
- package/dist/chunk-WXSTSC3D.cjs +0 -83
- package/dist/chunk-XSK7BWYO.js +0 -47
- package/dist/chunk-XVAPJ4PP.cjs +0 -449
- package/dist/chunk-XVASHRCE.cjs +0 -70
- package/dist/chunk-XYSMVQQD.cjs +0 -1608
- package/dist/chunk-YAIWI4Z5.js +0 -7
- package/dist/chunk-YGYOLDKR.js +0 -280
- package/dist/chunk-YP2PLNOF.cjs +0 -34
- package/dist/chunk-YSOLW4FS.cjs +0 -11
- package/dist/chunk-YY6OUR2U.js +0 -44
- package/dist/chunk-YZWS7FDT.cjs +0 -409
- package/dist/chunk-Z5YGWL65.cjs +0 -39
- package/dist/chunk-ZHNDXNL4.js +0 -45
- package/dist/chunk-ZX3EDZ5C.cjs +0 -17
- package/dist/index.d.cts +0 -2019
|
@@ -0,0 +1,1768 @@
|
|
|
1
|
+
import { i as e, n as t } from "./getRuntime-DAPqFH2W.js";
|
|
2
|
+
import { create as n } from "zustand";
|
|
3
|
+
import { createJSONStorage as r, persist as i } from "zustand/middleware";
|
|
4
|
+
import { v4 as a, v4 as o } from "uuid";
|
|
5
|
+
//#region src/utils/uuid.ts
|
|
6
|
+
function s() {
|
|
7
|
+
return a();
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/domain/entities/Window.ts
|
|
11
|
+
var c = (e) => ({
|
|
12
|
+
alwaysOnTop: !1,
|
|
13
|
+
...e,
|
|
14
|
+
id: s(),
|
|
15
|
+
isOpen: !0,
|
|
16
|
+
state: "normal",
|
|
17
|
+
zIndex: 0
|
|
18
|
+
}), l = (e) => ({
|
|
19
|
+
...e,
|
|
20
|
+
id: s()
|
|
21
|
+
}), u = (e) => ({
|
|
22
|
+
id: s(),
|
|
23
|
+
name: e.name,
|
|
24
|
+
fcIcon: e.fcIcon,
|
|
25
|
+
appIds: e.appIds ?? [],
|
|
26
|
+
isExpanded: e.isExpanded ?? !1,
|
|
27
|
+
isPredefined: e.isPredefined ?? !1,
|
|
28
|
+
order: e.order ?? 0
|
|
29
|
+
}), d = (e) => ({
|
|
30
|
+
id: s(),
|
|
31
|
+
name: e.name,
|
|
32
|
+
fcIcon: e.fcIcon,
|
|
33
|
+
appIds: e.appIds ?? [],
|
|
34
|
+
isExpanded: e.isExpanded ?? !1,
|
|
35
|
+
isPredefined: !0,
|
|
36
|
+
order: e.order ?? 0
|
|
37
|
+
}), f = (e, t) => ({
|
|
38
|
+
...e,
|
|
39
|
+
...t
|
|
40
|
+
}), p = (e, t = null, n = {}) => ({
|
|
41
|
+
id: s(),
|
|
42
|
+
name: e,
|
|
43
|
+
type: "folder",
|
|
44
|
+
parentId: t,
|
|
45
|
+
children: [],
|
|
46
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
47
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
48
|
+
...n
|
|
49
|
+
}), m = (e, t, n = null, r, i) => ({
|
|
50
|
+
id: s(),
|
|
51
|
+
name: e,
|
|
52
|
+
type: "file",
|
|
53
|
+
content: t,
|
|
54
|
+
mimeType: r,
|
|
55
|
+
parentId: n,
|
|
56
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
57
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
58
|
+
...i === void 0 ? {} : { url: i }
|
|
59
|
+
}), ee = 1e4, te = class {
|
|
60
|
+
windows = /* @__PURE__ */ new Map();
|
|
61
|
+
nextZIndex = 1;
|
|
62
|
+
assignZIndex(e) {
|
|
63
|
+
let t = this.nextZIndex++;
|
|
64
|
+
return e ? ee + t : t;
|
|
65
|
+
}
|
|
66
|
+
reset() {
|
|
67
|
+
this.windows.clear(), this.nextZIndex = 1;
|
|
68
|
+
}
|
|
69
|
+
loadWindows(e) {
|
|
70
|
+
this.windows.clear();
|
|
71
|
+
let t = 0;
|
|
72
|
+
for (let n of e) {
|
|
73
|
+
this.windows.set(n.id, n);
|
|
74
|
+
let e = n.alwaysOnTop ?? !1 ? n.zIndex - ee : n.zIndex;
|
|
75
|
+
e > t && (t = e);
|
|
76
|
+
}
|
|
77
|
+
this.nextZIndex = t + 1;
|
|
78
|
+
}
|
|
79
|
+
getAll() {
|
|
80
|
+
return Array.from(this.windows.values());
|
|
81
|
+
}
|
|
82
|
+
getById(e) {
|
|
83
|
+
return this.windows.get(e);
|
|
84
|
+
}
|
|
85
|
+
open(e) {
|
|
86
|
+
let t = c(e);
|
|
87
|
+
return t.zIndex = this.assignZIndex(t.alwaysOnTop ?? !1), this.windows.set(t.id, t), t;
|
|
88
|
+
}
|
|
89
|
+
close(e) {
|
|
90
|
+
this.windows.delete(e);
|
|
91
|
+
}
|
|
92
|
+
minimize(e) {
|
|
93
|
+
this.updateWindow(e, { state: "minimized" });
|
|
94
|
+
}
|
|
95
|
+
maximize(e) {
|
|
96
|
+
this.updateWindow(e, { state: "maximized" });
|
|
97
|
+
}
|
|
98
|
+
restore(e) {
|
|
99
|
+
this.updateWindow(e, { state: "normal" });
|
|
100
|
+
}
|
|
101
|
+
focus(e) {
|
|
102
|
+
let t = this.windows.get(e);
|
|
103
|
+
if (!t) return;
|
|
104
|
+
let n = this.assignZIndex(t.alwaysOnTop ?? !1);
|
|
105
|
+
this.updateWindow(e, { zIndex: n });
|
|
106
|
+
}
|
|
107
|
+
move(e, t, n) {
|
|
108
|
+
this.updateWindow(e, {
|
|
109
|
+
x: t,
|
|
110
|
+
y: n
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
resize(e, t, n) {
|
|
114
|
+
this.updateWindow(e, {
|
|
115
|
+
width: t,
|
|
116
|
+
height: n
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
updateWindow(e, t) {
|
|
120
|
+
let n = this.windows.get(e);
|
|
121
|
+
n && this.windows.set(e, {
|
|
122
|
+
...n,
|
|
123
|
+
...t
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}, ne = {
|
|
127
|
+
".txt": "text/plain",
|
|
128
|
+
".md": "text/markdown",
|
|
129
|
+
".markdown": "text/markdown",
|
|
130
|
+
".pdf": "application/pdf",
|
|
131
|
+
".jpg": "image/jpeg",
|
|
132
|
+
".jpeg": "image/jpeg",
|
|
133
|
+
".png": "image/png",
|
|
134
|
+
".gif": "image/gif",
|
|
135
|
+
".svg": "image/svg+xml",
|
|
136
|
+
".webp": "image/webp",
|
|
137
|
+
".bmp": "image/bmp",
|
|
138
|
+
".html": "text/html",
|
|
139
|
+
".htm": "text/html",
|
|
140
|
+
".css": "text/css",
|
|
141
|
+
".js": "text/javascript",
|
|
142
|
+
".json": "application/json",
|
|
143
|
+
".xml": "text/xml",
|
|
144
|
+
".jsdos": "application/jsdos",
|
|
145
|
+
".zip": "application/zip"
|
|
146
|
+
};
|
|
147
|
+
function h(e) {
|
|
148
|
+
let t = e.lastIndexOf(".");
|
|
149
|
+
if (!(t === -1 || t === e.length - 1)) return ne[e.slice(t).toLowerCase()];
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/utils/hashBlob.ts
|
|
153
|
+
function re(e) {
|
|
154
|
+
let t = 5381;
|
|
155
|
+
for (let n = 0; n < e.length; n++) t = (t << 5) + t ^ e[n], t >>>= 0;
|
|
156
|
+
return t.toString(16).padStart(8, "0") + e.length.toString(16).padStart(8, "0");
|
|
157
|
+
}
|
|
158
|
+
async function g(e) {
|
|
159
|
+
let t = await e.arrayBuffer(), n = new Uint8Array(t);
|
|
160
|
+
if (crypto?.subtle) {
|
|
161
|
+
let e = await crypto.subtle.digest("SHA-256", n);
|
|
162
|
+
return Array.from(new Uint8Array(e)).map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
163
|
+
}
|
|
164
|
+
return console.warn("[hashBlob] crypto.subtle unavailable (non-secure context), using fallback hash"), re(n);
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/infrastructure/adapters/IndexedDBFileSystem.ts
|
|
168
|
+
var ie = "fde-desktop-fs", _ = "nodes", v = "blobs", y = "metadata", ae = 2, oe = class {
|
|
169
|
+
db = null;
|
|
170
|
+
nodes = /* @__PURE__ */ new Map();
|
|
171
|
+
ready = !1;
|
|
172
|
+
initPromise = null;
|
|
173
|
+
persistQueue = [];
|
|
174
|
+
persistScheduled = !1;
|
|
175
|
+
async initialize() {
|
|
176
|
+
return this.initPromise ||= this.doInitialize(), this.initPromise;
|
|
177
|
+
}
|
|
178
|
+
async doInitialize() {
|
|
179
|
+
await this.openDatabase(), await this.loadNodes(), await this.migrateFromLocalStorage(), this.ready = !0;
|
|
180
|
+
}
|
|
181
|
+
openDatabase() {
|
|
182
|
+
return new Promise((e, t) => {
|
|
183
|
+
let n = indexedDB.open(ie, ae);
|
|
184
|
+
n.onerror = () => t(n.error), n.onsuccess = () => {
|
|
185
|
+
this.db = n.result, e();
|
|
186
|
+
}, n.onupgradeneeded = () => {
|
|
187
|
+
let e = n.result;
|
|
188
|
+
e.objectStoreNames.contains(_) || e.createObjectStore(_), e.objectStoreNames.contains(v) || e.createObjectStore(v), e.objectStoreNames.contains(y) || e.createObjectStore(y);
|
|
189
|
+
};
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
async loadNodes() {
|
|
193
|
+
if (this.db) return new Promise((e, t) => {
|
|
194
|
+
let n = this.db.transaction(_, "readonly"), r = n.objectStore(_).getAll();
|
|
195
|
+
r.onsuccess = () => {
|
|
196
|
+
let i = n.objectStore(_).getAllKeys();
|
|
197
|
+
i.onsuccess = () => {
|
|
198
|
+
let t = r.result, n = i.result;
|
|
199
|
+
for (let e = 0; e < t.length; e++) {
|
|
200
|
+
let r = String(n[e]);
|
|
201
|
+
this.nodes.set(r, t[e]);
|
|
202
|
+
}
|
|
203
|
+
e();
|
|
204
|
+
}, i.onerror = () => t(i.error);
|
|
205
|
+
}, r.onerror = () => t(r.error);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
async migrateFromLocalStorage() {
|
|
209
|
+
let e = "fran-desktop:filesystem", t = localStorage.getItem(e);
|
|
210
|
+
if (t && this.nodes.size === 0) try {
|
|
211
|
+
let n = JSON.parse(t);
|
|
212
|
+
for (let [e, t] of n) this.nodes.set(e, t);
|
|
213
|
+
await this.persistAllNodes(), localStorage.removeItem(e);
|
|
214
|
+
} catch {}
|
|
215
|
+
}
|
|
216
|
+
isReady() {
|
|
217
|
+
return this.ready;
|
|
218
|
+
}
|
|
219
|
+
async reinitialize() {
|
|
220
|
+
this.ready || await this.initialize();
|
|
221
|
+
}
|
|
222
|
+
persistAllNodes() {
|
|
223
|
+
return this.db ? new Promise((e, t) => {
|
|
224
|
+
let n = this.db.transaction(_, "readwrite"), r = n.objectStore(_);
|
|
225
|
+
for (let [e, t] of this.nodes.entries()) r.put(t, e);
|
|
226
|
+
n.oncomplete = () => e(), n.onerror = () => t(n.error);
|
|
227
|
+
}) : Promise.resolve();
|
|
228
|
+
}
|
|
229
|
+
schedulePersist() {
|
|
230
|
+
this.persistScheduled || (this.persistScheduled = !0, queueMicrotask(() => {
|
|
231
|
+
this.persistScheduled = !1, this.flushPersistQueue();
|
|
232
|
+
}));
|
|
233
|
+
}
|
|
234
|
+
flushPersistQueue() {
|
|
235
|
+
if (!this.db || this.persistQueue.length === 0) return;
|
|
236
|
+
let e = [...this.persistQueue];
|
|
237
|
+
this.persistQueue = [];
|
|
238
|
+
let t = this.db.transaction(_, "readwrite"), n = t.objectStore(_);
|
|
239
|
+
t.onerror = () => {
|
|
240
|
+
console.error("IndexedDB write failed", t.error);
|
|
241
|
+
};
|
|
242
|
+
for (let t of e) t.type === "set" ? n.put(t.value, t.key) : t.type === "delete" && n.delete(t.key);
|
|
243
|
+
}
|
|
244
|
+
persistNode(e, t) {
|
|
245
|
+
this.persistQueue.push({
|
|
246
|
+
type: "set",
|
|
247
|
+
key: e,
|
|
248
|
+
value: t
|
|
249
|
+
}), this.schedulePersist();
|
|
250
|
+
}
|
|
251
|
+
deleteNodeFromPersist(e) {
|
|
252
|
+
this.persistQueue.push({
|
|
253
|
+
type: "delete",
|
|
254
|
+
key: e
|
|
255
|
+
}), this.schedulePersist();
|
|
256
|
+
}
|
|
257
|
+
async saveBlob(e) {
|
|
258
|
+
this.db || await this.initialize();
|
|
259
|
+
let t = await g(e);
|
|
260
|
+
return await this.getBlob(`idb://${t}`) ? `idb://${t}` : new Promise((n, r) => {
|
|
261
|
+
let i = this.db.transaction(v, "readwrite").objectStore(v).put(e, t);
|
|
262
|
+
i.onsuccess = () => n(`idb://${t}`), i.onerror = () => r(i.error);
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
async getBlob(e) {
|
|
266
|
+
this.db || await this.initialize();
|
|
267
|
+
let t = e.startsWith("idb://") ? e.slice(6) : e;
|
|
268
|
+
return new Promise((e, n) => {
|
|
269
|
+
let r = this.db.transaction(v, "readonly").objectStore(v).get(t);
|
|
270
|
+
r.onsuccess = () => e(r.result ?? null), r.onerror = () => n(r.error);
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
async toBlobUrl(e) {
|
|
274
|
+
if (!e.startsWith("idb://")) return null;
|
|
275
|
+
let t = await this.getBlob(e);
|
|
276
|
+
return t ? URL.createObjectURL(t) : null;
|
|
277
|
+
}
|
|
278
|
+
async clearBlobs() {
|
|
279
|
+
if (this.db) return new Promise((e, t) => {
|
|
280
|
+
let n = this.db.transaction(v, "readwrite").objectStore(v).clear();
|
|
281
|
+
n.onsuccess = () => e(), n.onerror = () => t(n.error);
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
async readFile(e) {
|
|
285
|
+
return "";
|
|
286
|
+
}
|
|
287
|
+
async writeFile(e, t) {}
|
|
288
|
+
getNode(e) {
|
|
289
|
+
return this.nodes.get(e);
|
|
290
|
+
}
|
|
291
|
+
getChildren(e) {
|
|
292
|
+
let t = this.nodes.get(e);
|
|
293
|
+
return !t || t.type !== "folder" ? [] : t.children.map((e) => this.nodes.get(e)).filter((e) => e !== void 0);
|
|
294
|
+
}
|
|
295
|
+
getRootNodes() {
|
|
296
|
+
return Array.from(this.nodes.values()).filter((e) => e.parentId === null);
|
|
297
|
+
}
|
|
298
|
+
getAllNodes() {
|
|
299
|
+
return Array.from(this.nodes.values());
|
|
300
|
+
}
|
|
301
|
+
isEmpty() {
|
|
302
|
+
return this.nodes.size === 0;
|
|
303
|
+
}
|
|
304
|
+
async createFile(e, t, n, r) {
|
|
305
|
+
let i = m(e, t, n, h(e), r);
|
|
306
|
+
return this.nodes.set(i.id, i), n && this.addChildToFolder(n, i.id), this.persistNode(i.id, i), i;
|
|
307
|
+
}
|
|
308
|
+
async createFolder(e, t, n, r) {
|
|
309
|
+
let i = p(e, t, {
|
|
310
|
+
iconName: n,
|
|
311
|
+
iconColor: r
|
|
312
|
+
});
|
|
313
|
+
return this.nodes.set(i.id, i), t && this.addChildToFolder(t, i.id), this.persistNode(i.id, i), i;
|
|
314
|
+
}
|
|
315
|
+
async updateFile(e, t) {
|
|
316
|
+
let n = this.nodes.get(e);
|
|
317
|
+
if (!n || n.type !== "file") throw Error(`File not found: ${e}`);
|
|
318
|
+
let r = {
|
|
319
|
+
...n,
|
|
320
|
+
content: t,
|
|
321
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
322
|
+
};
|
|
323
|
+
return this.nodes.set(e, r), this.persistNode(e, r), r;
|
|
324
|
+
}
|
|
325
|
+
async move(e, t) {
|
|
326
|
+
let n = this.nodes.get(e);
|
|
327
|
+
if (!n) throw Error(`Node not found: ${e}`);
|
|
328
|
+
if (t === e) throw Error("Cannot move a folder into itself");
|
|
329
|
+
if (t !== null) {
|
|
330
|
+
let n = t;
|
|
331
|
+
for (; n !== null;) {
|
|
332
|
+
if (n === e) throw Error("Cannot move a folder into one of its descendants");
|
|
333
|
+
n = this.nodes.get(n)?.parentId ?? null;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
n.parentId && this.removeChildFromParent(n);
|
|
337
|
+
let r = {
|
|
338
|
+
...n,
|
|
339
|
+
parentId: t
|
|
340
|
+
};
|
|
341
|
+
return this.nodes.set(e, r), t && this.addChildToFolder(t, e), this.persistNode(e, r), r;
|
|
342
|
+
}
|
|
343
|
+
async delete(e) {
|
|
344
|
+
let t = this.nodes.get(e);
|
|
345
|
+
t && (t.type === "folder" && this.deleteRecursive(t), this.removeChildFromParent(t), this.nodes.delete(e), this.deleteNodeFromPersist(e));
|
|
346
|
+
}
|
|
347
|
+
async getManifestSha() {
|
|
348
|
+
return this.db || await this.initialize(), new Promise((e, t) => {
|
|
349
|
+
let n = this.db.transaction(y, "readonly").objectStore(y).get("manifestSha");
|
|
350
|
+
n.onsuccess = () => e(n.result ?? null), n.onerror = () => t(n.error);
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
async saveManifestSha(e) {
|
|
354
|
+
return this.db || await this.initialize(), new Promise((t, n) => {
|
|
355
|
+
let r = this.db.transaction(y, "readwrite").objectStore(y).put(e, "manifestSha");
|
|
356
|
+
r.onsuccess = () => t(), r.onerror = () => n(r.error);
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
async clearAll() {
|
|
360
|
+
this.nodes.clear(), this.ready = !1, this.initPromise = null, this.db &&= (await Promise.all([
|
|
361
|
+
new Promise((e, t) => {
|
|
362
|
+
let n = this.db.transaction(_, "readwrite");
|
|
363
|
+
n.objectStore(_).clear(), n.oncomplete = () => e(), n.onerror = () => t(n.error);
|
|
364
|
+
}),
|
|
365
|
+
new Promise((e, t) => {
|
|
366
|
+
let n = this.db.transaction(v, "readwrite");
|
|
367
|
+
n.objectStore(v).clear(), n.oncomplete = () => e(), n.onerror = () => t(n.error);
|
|
368
|
+
}),
|
|
369
|
+
new Promise((e, t) => {
|
|
370
|
+
let n = this.db.transaction(y, "readwrite");
|
|
371
|
+
n.objectStore(y).clear(), n.oncomplete = () => e(), n.onerror = () => t(n.error);
|
|
372
|
+
})
|
|
373
|
+
]), this.db.close(), null);
|
|
374
|
+
}
|
|
375
|
+
async seed(e) {
|
|
376
|
+
let t = this.buildFolderMapFromManifest(e);
|
|
377
|
+
for (let n of e.files) {
|
|
378
|
+
let e = t.get(n.folder), r = m(n.name, "", e?.id ?? null, n.mimeType, n.url);
|
|
379
|
+
if (this.nodes.set(r.id, r), e) {
|
|
380
|
+
let i = {
|
|
381
|
+
...e,
|
|
382
|
+
children: [...e.children, r.id]
|
|
383
|
+
};
|
|
384
|
+
this.nodes.set(e.id, i), t.set(n.folder, i);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
await this.persistAllNodes();
|
|
388
|
+
}
|
|
389
|
+
async mergeSeed(e) {
|
|
390
|
+
let t = this.buildFolderMapFromManifest(e, !0);
|
|
391
|
+
for (let n of e.files) {
|
|
392
|
+
let e = t.get(n.folder);
|
|
393
|
+
if (!e) continue;
|
|
394
|
+
let r = this.getChildren(e.id).find((e) => e.type === "file" && e.name === n.name);
|
|
395
|
+
if (r) {
|
|
396
|
+
if (r.url !== n.url) {
|
|
397
|
+
let e = {
|
|
398
|
+
...r,
|
|
399
|
+
url: n.url
|
|
400
|
+
};
|
|
401
|
+
this.nodes.set(r.id, e);
|
|
402
|
+
}
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
let i = m(n.name, "", e.id, n.mimeType, n.url);
|
|
406
|
+
this.nodes.set(i.id, i);
|
|
407
|
+
let a = {
|
|
408
|
+
...e,
|
|
409
|
+
children: [...e.children, i.id]
|
|
410
|
+
};
|
|
411
|
+
this.nodes.set(e.id, a), t.set(n.folder, a);
|
|
412
|
+
}
|
|
413
|
+
await this.persistAllNodes();
|
|
414
|
+
}
|
|
415
|
+
buildFolderMapFromManifest(e, t = !1) {
|
|
416
|
+
let n = /* @__PURE__ */ new Map(), r = [...new Set([...e.folders, ...e.files.map((e) => e.folder)])].sort((e, t) => e.split("/").length - t.split("/").length);
|
|
417
|
+
for (let e of r) {
|
|
418
|
+
let r = e.split("/"), i = r[r.length - 1], a = r.length > 1 ? r.slice(0, -1).join("/") : null, o = a ? n.get(a) : null, s = o?.id ?? null;
|
|
419
|
+
if (t) {
|
|
420
|
+
let t = (s ? this.getChildren(s) : this.getRootNodes()).find((e) => e.type === "folder" && e.name === i);
|
|
421
|
+
if (t) {
|
|
422
|
+
n.set(e, t);
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
let c = p(i, s);
|
|
427
|
+
if (this.nodes.set(c.id, c), n.set(e, c), o) {
|
|
428
|
+
let e = {
|
|
429
|
+
...o,
|
|
430
|
+
children: [...o.children, c.id]
|
|
431
|
+
};
|
|
432
|
+
this.nodes.set(o.id, e), n.set(a, e);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return n;
|
|
436
|
+
}
|
|
437
|
+
addChildToFolder(e, t) {
|
|
438
|
+
let n = this.nodes.get(e);
|
|
439
|
+
if (!n || n.type !== "folder") return;
|
|
440
|
+
let r = {
|
|
441
|
+
...n,
|
|
442
|
+
children: [...n.children, t]
|
|
443
|
+
};
|
|
444
|
+
this.nodes.set(e, r), this.persistNode(e, r);
|
|
445
|
+
}
|
|
446
|
+
removeChildFromParent(e) {
|
|
447
|
+
if (!e.parentId) return;
|
|
448
|
+
let t = this.nodes.get(e.parentId);
|
|
449
|
+
if (!t || t.type !== "folder") return;
|
|
450
|
+
let n = {
|
|
451
|
+
...t,
|
|
452
|
+
children: t.children.filter((t) => t !== e.id)
|
|
453
|
+
};
|
|
454
|
+
this.nodes.set(e.parentId, n), this.persistNode(e.parentId, n);
|
|
455
|
+
}
|
|
456
|
+
deleteRecursive(e) {
|
|
457
|
+
for (let t of e.children) {
|
|
458
|
+
let e = this.nodes.get(t);
|
|
459
|
+
e && (e.type === "folder" && this.deleteRecursive(e), this.nodes.delete(t), this.deleteNodeFromPersist(t));
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}, se = "/api/fs", ce = 6e4;
|
|
463
|
+
async function le(e, t = {}, n = ce) {
|
|
464
|
+
let r = new AbortController(), i = setTimeout(() => r.abort(), n);
|
|
465
|
+
try {
|
|
466
|
+
return await fetch(e, {
|
|
467
|
+
...t,
|
|
468
|
+
signal: r.signal
|
|
469
|
+
});
|
|
470
|
+
} finally {
|
|
471
|
+
clearTimeout(i);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
var b = se;
|
|
475
|
+
function ue(e) {
|
|
476
|
+
b = e;
|
|
477
|
+
}
|
|
478
|
+
var de = class {
|
|
479
|
+
nodes = /* @__PURE__ */ new Map();
|
|
480
|
+
pathToId = /* @__PURE__ */ new Map();
|
|
481
|
+
ready = !1;
|
|
482
|
+
rootFolderId;
|
|
483
|
+
initPromise = null;
|
|
484
|
+
constructor() {
|
|
485
|
+
this.rootFolderId = s(), this.pathToId.set("/", this.rootFolderId);
|
|
486
|
+
}
|
|
487
|
+
async initialize() {
|
|
488
|
+
return this.initPromise ||= this.doInitialize(), this.initPromise;
|
|
489
|
+
}
|
|
490
|
+
async doInitialize() {
|
|
491
|
+
try {
|
|
492
|
+
let e = await fetch(`${b}?action=readdir&path=/`);
|
|
493
|
+
if (e.ok) {
|
|
494
|
+
let t = await e.json();
|
|
495
|
+
await this.syncFromEntries(t, null);
|
|
496
|
+
}
|
|
497
|
+
} catch (e) {
|
|
498
|
+
console.warn("[DockerFS] Failed to initialize from server:", e);
|
|
499
|
+
}
|
|
500
|
+
this.ready = !0;
|
|
501
|
+
}
|
|
502
|
+
async reinitialize() {
|
|
503
|
+
this.ready = !1, this.nodes.clear(), this.pathToId.clear(), this.rootFolderId = s(), this.pathToId.set("/", this.rootFolderId), this.initPromise = null, await this.initialize();
|
|
504
|
+
}
|
|
505
|
+
isReady() {
|
|
506
|
+
return this.ready;
|
|
507
|
+
}
|
|
508
|
+
isEmpty() {
|
|
509
|
+
return this.nodes.size === 0;
|
|
510
|
+
}
|
|
511
|
+
getNode(e) {
|
|
512
|
+
return this.nodes.get(e);
|
|
513
|
+
}
|
|
514
|
+
getChildren(e) {
|
|
515
|
+
let t = [];
|
|
516
|
+
for (let n of this.nodes.values()) n.parentId === e && t.push(n);
|
|
517
|
+
return t;
|
|
518
|
+
}
|
|
519
|
+
getRootNodes() {
|
|
520
|
+
return Array.from(this.nodes.values()).filter((e) => e.parentId === null);
|
|
521
|
+
}
|
|
522
|
+
getAllNodes() {
|
|
523
|
+
return Array.from(this.nodes.values());
|
|
524
|
+
}
|
|
525
|
+
async createFile(e, t, n, r) {
|
|
526
|
+
let i = s(), a = n ? this.getPathFromId(n) : "/", o = a ? `${a}/${e}`.replace("//", "/") : `/${e}`, c = r ?? `/api/fs?action=file&path=${encodeURIComponent(o)}`, l = {
|
|
527
|
+
...m(e, t, n, this.getMimeType(e), c),
|
|
528
|
+
id: i
|
|
529
|
+
};
|
|
530
|
+
this.nodes.set(i, l), this.pathToId.set(o, i);
|
|
531
|
+
try {
|
|
532
|
+
await this.writeFileToServer(o, t);
|
|
533
|
+
} catch (e) {
|
|
534
|
+
throw this.nodes.delete(i), this.pathToId.delete(o), e;
|
|
535
|
+
}
|
|
536
|
+
return l;
|
|
537
|
+
}
|
|
538
|
+
async createFolder(e, t, n, r) {
|
|
539
|
+
let i = s(), a = t ? this.getPathFromId(t) : "/", o = a ? `${a}/${e}`.replace("//", "/") : `/${e}`, c = {};
|
|
540
|
+
n && (c.iconName = n), r && (c.iconColor = r);
|
|
541
|
+
let l = {
|
|
542
|
+
...p(e, t, c),
|
|
543
|
+
id: i
|
|
544
|
+
};
|
|
545
|
+
this.nodes.set(i, l), this.pathToId.set(o, i);
|
|
546
|
+
try {
|
|
547
|
+
await this.createDirOnServer(o, c);
|
|
548
|
+
} catch (e) {
|
|
549
|
+
throw this.nodes.delete(i), this.pathToId.delete(o), e;
|
|
550
|
+
}
|
|
551
|
+
return l;
|
|
552
|
+
}
|
|
553
|
+
async updateFile(e, t) {
|
|
554
|
+
let n = this.nodes.get(e);
|
|
555
|
+
if (!n || n.type !== "file") throw Error(`File not found: ${e}`);
|
|
556
|
+
let r = n, i = this.getPathFromId(e), a = {
|
|
557
|
+
...r,
|
|
558
|
+
content: t,
|
|
559
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
560
|
+
};
|
|
561
|
+
return this.nodes.set(e, a), i && this.writeFileToServer(i, t).catch((e) => {
|
|
562
|
+
console.warn("[DockerFS] Failed to update file on server:", e);
|
|
563
|
+
}), a;
|
|
564
|
+
}
|
|
565
|
+
async move(e, t) {
|
|
566
|
+
let n = this.nodes.get(e);
|
|
567
|
+
if (!n) throw Error(`Node not found: ${e}`);
|
|
568
|
+
if (t === e) throw Error("Cannot move a folder into itself");
|
|
569
|
+
if (t !== null) {
|
|
570
|
+
let n = t;
|
|
571
|
+
for (; n !== null;) {
|
|
572
|
+
if (n === e) throw Error("Cannot move a folder into one of its descendants");
|
|
573
|
+
n = this.nodes.get(n)?.parentId ?? null;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
let r = this.getPathFromId(e), i = t ? this.getPathFromId(t) : "/", a = i ? `${i}/${n.name}`.replace("//", "/") : `/${n.name}`;
|
|
577
|
+
if (!r) throw Error(`Cannot determine path for node ${e}`);
|
|
578
|
+
if (!i && t !== null) throw Error(`Cannot determine parent path for ${t}`);
|
|
579
|
+
let o = await le(`${b}?action=move&oldPath=${encodeURIComponent(r)}&newPath=${encodeURIComponent(a)}`);
|
|
580
|
+
if (!o.ok) {
|
|
581
|
+
let e = await o.json().catch(() => ({}));
|
|
582
|
+
throw Error(e.error || `HTTP ${o.status}`);
|
|
583
|
+
}
|
|
584
|
+
let s = {
|
|
585
|
+
...n,
|
|
586
|
+
parentId: t
|
|
587
|
+
};
|
|
588
|
+
return this.nodes.set(e, s), this.pathToId.delete(r), this.pathToId.set(a, e), s;
|
|
589
|
+
}
|
|
590
|
+
async delete(e) {
|
|
591
|
+
let t = this.getPathFromId(e);
|
|
592
|
+
if (this.deleteRecursive(e), t) try {
|
|
593
|
+
await this.deleteFromServer(t);
|
|
594
|
+
} catch (e) {
|
|
595
|
+
throw console.warn(`[DockerFS] Failed to delete ${t} on server:`, e), e;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
async readFile(e) {
|
|
599
|
+
try {
|
|
600
|
+
let t = await fetch(`${b}?action=read&path=${encodeURIComponent(e)}`);
|
|
601
|
+
if (t.ok) return (await t.json()).content;
|
|
602
|
+
} catch (t) {
|
|
603
|
+
console.warn(`[DockerFS] Failed to read file ${e}:`, t);
|
|
604
|
+
}
|
|
605
|
+
return "";
|
|
606
|
+
}
|
|
607
|
+
async writeFile(e, t) {
|
|
608
|
+
await this.writeFileToServer(e, t);
|
|
609
|
+
}
|
|
610
|
+
async saveBlob(e) {
|
|
611
|
+
let t = `/.blobs/${await g(e)}.${e.type.split("/")[1] || "bin"}`;
|
|
612
|
+
try {
|
|
613
|
+
await fetch(`${b}?action=writeBinary&path=${encodeURIComponent(t)}`, {
|
|
614
|
+
method: "POST",
|
|
615
|
+
body: e
|
|
616
|
+
});
|
|
617
|
+
} catch (e) {
|
|
618
|
+
console.warn(`[DockerFS] Failed to save blob ${t}:`, e);
|
|
619
|
+
}
|
|
620
|
+
return `/api/fs?action=file&path=${encodeURIComponent(t)}`;
|
|
621
|
+
}
|
|
622
|
+
async getBlob(e) {
|
|
623
|
+
if (!e.startsWith("/api/fs")) return null;
|
|
624
|
+
try {
|
|
625
|
+
let t = await fetch(e);
|
|
626
|
+
return t.ok ? await t.blob() : null;
|
|
627
|
+
} catch {
|
|
628
|
+
return null;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
async toBlobUrl(e) {
|
|
632
|
+
if (!e.startsWith("/api/fs")) return null;
|
|
633
|
+
try {
|
|
634
|
+
let t = await fetch(e);
|
|
635
|
+
if (!t.ok) return null;
|
|
636
|
+
let n = await t.blob();
|
|
637
|
+
return URL.createObjectURL(n);
|
|
638
|
+
} catch {
|
|
639
|
+
return null;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
async getManifestSha() {
|
|
643
|
+
return null;
|
|
644
|
+
}
|
|
645
|
+
async saveManifestSha(e) {}
|
|
646
|
+
seed(e) {
|
|
647
|
+
return Promise.resolve();
|
|
648
|
+
}
|
|
649
|
+
mergeSeed(e) {
|
|
650
|
+
return Promise.resolve();
|
|
651
|
+
}
|
|
652
|
+
async clearAll() {
|
|
653
|
+
this.nodes.clear(), this.pathToId.clear(), this.ready = !1, this.initPromise = null, this.rootFolderId = s(), this.pathToId.set("/", this.rootFolderId);
|
|
654
|
+
}
|
|
655
|
+
getMimeType(e) {
|
|
656
|
+
return h(e) || "application/octet-stream";
|
|
657
|
+
}
|
|
658
|
+
getPathFromId(e) {
|
|
659
|
+
if (!e) return null;
|
|
660
|
+
for (let [t, n] of this.pathToId.entries()) if (n === e) return t;
|
|
661
|
+
let t = this.nodes.get(e);
|
|
662
|
+
if (!t) return null;
|
|
663
|
+
if (!t.parentId) return `/${t.name}`;
|
|
664
|
+
let n = this.getPathFromId(t.parentId);
|
|
665
|
+
return n ? `${n}/${t.name}` : null;
|
|
666
|
+
}
|
|
667
|
+
deleteRecursive(e) {
|
|
668
|
+
for (let t of this.getChildren(e)) this.deleteRecursive(t.id);
|
|
669
|
+
this.nodes.delete(e);
|
|
670
|
+
for (let [t, n] of this.pathToId.entries()) n === e && this.pathToId.delete(t);
|
|
671
|
+
}
|
|
672
|
+
async syncFromEntries(e, t) {
|
|
673
|
+
for (let n of e) {
|
|
674
|
+
let e = s();
|
|
675
|
+
if (n.type === "directory") {
|
|
676
|
+
let r = p(n.name, t);
|
|
677
|
+
this.nodes.set(e, {
|
|
678
|
+
...r,
|
|
679
|
+
id: e
|
|
680
|
+
}), this.pathToId.set(n.path, e);
|
|
681
|
+
let i = await this.fetchReaddir(n.path);
|
|
682
|
+
await this.syncFromEntries(i, e);
|
|
683
|
+
} else {
|
|
684
|
+
let r = `/api/fs?action=file&path=${encodeURIComponent(n.path)}`, i = m(n.name, "", t, this.getMimeType(n.name), r);
|
|
685
|
+
this.nodes.set(e, {
|
|
686
|
+
...i,
|
|
687
|
+
id: e
|
|
688
|
+
}), this.pathToId.set(n.path, e);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
async fetchReaddir(e) {
|
|
693
|
+
try {
|
|
694
|
+
let t = await fetch(`${b}?action=readdir&path=${encodeURIComponent(e)}`);
|
|
695
|
+
if (t.ok) return await t.json();
|
|
696
|
+
} catch (t) {
|
|
697
|
+
console.warn(`[DockerFS] Failed to readdir ${e}:`, t);
|
|
698
|
+
}
|
|
699
|
+
return [];
|
|
700
|
+
}
|
|
701
|
+
async writeFileToServer(e, t) {
|
|
702
|
+
let n = await fetch(`${b}`, {
|
|
703
|
+
method: "POST",
|
|
704
|
+
headers: { "Content-Type": "application/json" },
|
|
705
|
+
body: JSON.stringify({
|
|
706
|
+
path: e,
|
|
707
|
+
content: t
|
|
708
|
+
})
|
|
709
|
+
});
|
|
710
|
+
if (!n.ok) throw Error(`Failed to write file ${e}: HTTP ${n.status}`);
|
|
711
|
+
}
|
|
712
|
+
async createDirOnServer(e, t) {
|
|
713
|
+
let n = await fetch(`${b}`, {
|
|
714
|
+
method: "PUT",
|
|
715
|
+
headers: { "Content-Type": "application/json" },
|
|
716
|
+
body: JSON.stringify({
|
|
717
|
+
path: e,
|
|
718
|
+
...t
|
|
719
|
+
})
|
|
720
|
+
});
|
|
721
|
+
if (!n.ok) throw Error(`Failed to create directory ${e}: HTTP ${n.status}`);
|
|
722
|
+
}
|
|
723
|
+
async deleteFromServer(e) {
|
|
724
|
+
try {
|
|
725
|
+
await fetch(`${b}?path=${encodeURIComponent(e)}`, { method: "DELETE" });
|
|
726
|
+
} catch (t) {
|
|
727
|
+
console.warn(`[DockerFS] Failed to delete ${e}:`, t);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}, x = "launcher-folder-custom-apps", S = [
|
|
731
|
+
{
|
|
732
|
+
id: "launcher-folder-social-links",
|
|
733
|
+
name: "Social Links",
|
|
734
|
+
fcIcon: "VscAccount",
|
|
735
|
+
appIds: ["github", "linkedin"],
|
|
736
|
+
isExpanded: !1,
|
|
737
|
+
isPredefined: !0,
|
|
738
|
+
order: 0
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
id: "launcher-folder-office",
|
|
742
|
+
name: "Office and media",
|
|
743
|
+
fcIcon: "VscLibrary",
|
|
744
|
+
appIds: [
|
|
745
|
+
"notepad",
|
|
746
|
+
"pdf",
|
|
747
|
+
"image-viewer"
|
|
748
|
+
],
|
|
749
|
+
isExpanded: !1,
|
|
750
|
+
isPredefined: !0,
|
|
751
|
+
order: 1
|
|
752
|
+
},
|
|
753
|
+
{
|
|
754
|
+
id: "launcher-folder-programming",
|
|
755
|
+
name: "Programming",
|
|
756
|
+
fcIcon: "VscGitPullRequest",
|
|
757
|
+
appIds: [
|
|
758
|
+
"terminal",
|
|
759
|
+
"code-server",
|
|
760
|
+
"device-info",
|
|
761
|
+
"storybook"
|
|
762
|
+
],
|
|
763
|
+
isExpanded: !1,
|
|
764
|
+
isPredefined: !0,
|
|
765
|
+
order: 2
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
id: "launcher-folder-games",
|
|
769
|
+
name: "Games",
|
|
770
|
+
fcIcon: "VscGame",
|
|
771
|
+
appIds: ["dos-emulator", "doom"],
|
|
772
|
+
isExpanded: !1,
|
|
773
|
+
isPredefined: !0,
|
|
774
|
+
order: 3
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
id: x,
|
|
778
|
+
name: "Custom Apps",
|
|
779
|
+
fcIcon: "VscExtensions",
|
|
780
|
+
appIds: [],
|
|
781
|
+
isExpanded: !1,
|
|
782
|
+
isPredefined: !0,
|
|
783
|
+
order: 4
|
|
784
|
+
}
|
|
785
|
+
], C = [...S], w = null, T = null, E = 0, fe = 5e3, D = "/dist-apps/apps-manifest.json";
|
|
786
|
+
async function O(e = !1) {
|
|
787
|
+
let t = Date.now();
|
|
788
|
+
if (!e && w && t - E < fe) return w;
|
|
789
|
+
if (T) return T;
|
|
790
|
+
let n = `${D}?t=${t}`;
|
|
791
|
+
return T = fetch(n).then(async (e) => {
|
|
792
|
+
if (!e.ok) {
|
|
793
|
+
if (e.status === 404) return console.warn("[CustomApps] No apps manifest found at", D), null;
|
|
794
|
+
throw Error(`Failed to fetch manifest: ${e.status}`);
|
|
795
|
+
}
|
|
796
|
+
return e.json();
|
|
797
|
+
}).then((e) => (w = e, E = Date.now(), T = null, console.log(`[CustomApps] Loaded manifest with ${e.apps.length} apps`), e)).catch((e) => (console.error("[CustomApps] Error fetching manifest:", e), T = null, null)), T;
|
|
798
|
+
}
|
|
799
|
+
function pe() {
|
|
800
|
+
return w;
|
|
801
|
+
}
|
|
802
|
+
function k() {
|
|
803
|
+
w = null, E = 0;
|
|
804
|
+
}
|
|
805
|
+
function me(e) {
|
|
806
|
+
if (!w) {
|
|
807
|
+
w = {
|
|
808
|
+
version: "1.0.0",
|
|
809
|
+
generated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
810
|
+
apps: [e]
|
|
811
|
+
};
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
w = w.apps.some((t) => t.id === e.id) ? {
|
|
815
|
+
...w,
|
|
816
|
+
apps: w.apps.map((t) => t.id === e.id ? e : t)
|
|
817
|
+
} : {
|
|
818
|
+
...w,
|
|
819
|
+
apps: [...w.apps, e]
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
function he(e) {
|
|
823
|
+
w &&= {
|
|
824
|
+
...w,
|
|
825
|
+
apps: w.apps.filter((t) => t.id !== e)
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
async function ge() {
|
|
829
|
+
return (await O())?.apps ?? [];
|
|
830
|
+
}
|
|
831
|
+
async function _e(e) {
|
|
832
|
+
return (await ge()).find((t) => t.id === e);
|
|
833
|
+
}
|
|
834
|
+
function ve(e) {
|
|
835
|
+
return w ? w.apps.some((t) => t.id === e) : !1;
|
|
836
|
+
}
|
|
837
|
+
function ye(e) {
|
|
838
|
+
return {
|
|
839
|
+
id: e.id,
|
|
840
|
+
name: e.name,
|
|
841
|
+
icon: e.icon,
|
|
842
|
+
...e.iconUrl && { iconUrl: e.iconUrl },
|
|
843
|
+
defaultWidth: e.window.defaultWidth,
|
|
844
|
+
defaultHeight: e.window.defaultHeight,
|
|
845
|
+
minWidth: e.window.minWidth === !1 ? void 0 : e.window.minWidth,
|
|
846
|
+
minHeight: e.window.minHeight === !1 ? void 0 : e.window.minHeight,
|
|
847
|
+
canMaximize: e.window.canMaximize,
|
|
848
|
+
alwaysOnTop: e.window.alwaysOnTop
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
function be(e, t) {
|
|
852
|
+
let n = new Set(t.map((e) => e.id)), r = e.filter((e) => !n.has(e.id)), i = t.map((e) => {
|
|
853
|
+
let t = {
|
|
854
|
+
id: e.id,
|
|
855
|
+
name: e.name,
|
|
856
|
+
icon: e.icon,
|
|
857
|
+
defaultWidth: e.window.defaultWidth ?? 800,
|
|
858
|
+
defaultHeight: e.window.defaultHeight ?? 600,
|
|
859
|
+
minWidth: e.window.minWidth === !1 ? void 0 : e.window.minWidth,
|
|
860
|
+
minHeight: e.window.minHeight === !1 ? void 0 : e.window.minHeight,
|
|
861
|
+
canMaximize: e.window.canMaximize ?? !0,
|
|
862
|
+
alwaysOnTop: e.window.alwaysOnTop ?? !1
|
|
863
|
+
};
|
|
864
|
+
return e.iconUrl && (t.iconUrl = e.iconUrl), t;
|
|
865
|
+
});
|
|
866
|
+
return [...r, ...i];
|
|
867
|
+
}
|
|
868
|
+
async function xe(e) {
|
|
869
|
+
k();
|
|
870
|
+
let t = await O(!0);
|
|
871
|
+
if (!t) return {
|
|
872
|
+
added: [],
|
|
873
|
+
removed: [],
|
|
874
|
+
manifest: null
|
|
875
|
+
};
|
|
876
|
+
let n = Object.keys(e), r = t.apps.map((e) => e.id);
|
|
877
|
+
return {
|
|
878
|
+
added: t.apps.filter((e) => !n.includes(e.id)),
|
|
879
|
+
removed: n.filter((e) => !r.includes(e)),
|
|
880
|
+
manifest: t
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
//#endregion
|
|
884
|
+
//#region src/utils/sortNodes.ts
|
|
885
|
+
var A = (e) => {
|
|
886
|
+
let t = e.filter((e) => e.type === "folder"), n = e.filter((e) => e.type === "file"), r = (e, t) => e.name.localeCompare(t.name);
|
|
887
|
+
return [...t.sort(r), ...n.sort(r)];
|
|
888
|
+
}, Se = {
|
|
889
|
+
BY_TYPE: "byType",
|
|
890
|
+
BY_NAME: "byName",
|
|
891
|
+
BY_DATE: "byDate"
|
|
892
|
+
};
|
|
893
|
+
function j(e) {
|
|
894
|
+
return e.nodeId ? e.appId === "files" ? "folder" : "file" : "app";
|
|
895
|
+
}
|
|
896
|
+
var M = {
|
|
897
|
+
app: 0,
|
|
898
|
+
folder: 1,
|
|
899
|
+
file: 2
|
|
900
|
+
};
|
|
901
|
+
function N(e, t) {
|
|
902
|
+
return [...e].sort((e, n) => {
|
|
903
|
+
let r = j(e), i = j(n);
|
|
904
|
+
if (r !== i) return M[r] - M[i];
|
|
905
|
+
if (r === "app") {
|
|
906
|
+
if (!t) return e.name.localeCompare(n.name);
|
|
907
|
+
let r = t.indexOf(e.appId), i = t.indexOf(n.appId);
|
|
908
|
+
return (r === -1 ? Infinity : r) - (i === -1 ? Infinity : i);
|
|
909
|
+
}
|
|
910
|
+
return e.name.localeCompare(n.name);
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
var P = (e, t) => {
|
|
914
|
+
switch (t) {
|
|
915
|
+
case "default": return N(e);
|
|
916
|
+
case "name-asc": return [...e].sort((e, t) => e.name.localeCompare(t.name));
|
|
917
|
+
case "name-desc": return [...e].sort((e, t) => t.name.localeCompare(e.name));
|
|
918
|
+
case "type": return [...e].sort((e, t) => {
|
|
919
|
+
let n = j(e), r = j(t);
|
|
920
|
+
return n === r ? e.name.localeCompare(t.name) : M[n] - M[r];
|
|
921
|
+
});
|
|
922
|
+
default: return N(e);
|
|
923
|
+
}
|
|
924
|
+
}, Ce = (e, t) => {
|
|
925
|
+
switch (t) {
|
|
926
|
+
case "default":
|
|
927
|
+
case "type": return A(e);
|
|
928
|
+
case "name-asc": return [...e].sort((e, t) => e.name.localeCompare(t.name));
|
|
929
|
+
case "name-desc": return [...e].sort((e, t) => t.name.localeCompare(e.name));
|
|
930
|
+
default: return A(e);
|
|
931
|
+
}
|
|
932
|
+
}, F = {
|
|
933
|
+
defaultWidth: 800,
|
|
934
|
+
defaultHeight: 600,
|
|
935
|
+
minWidth: 640,
|
|
936
|
+
minHeight: 480
|
|
937
|
+
}, I = [
|
|
938
|
+
{
|
|
939
|
+
id: "files",
|
|
940
|
+
name: "FilesApp",
|
|
941
|
+
icon: "📁",
|
|
942
|
+
fcIcon: "FcOpenedFolder",
|
|
943
|
+
hasContextMenu: !0,
|
|
944
|
+
...F
|
|
945
|
+
},
|
|
946
|
+
{
|
|
947
|
+
id: "settings",
|
|
948
|
+
name: "Settings",
|
|
949
|
+
icon: "⚙️",
|
|
950
|
+
fcIcon: "FcSettings",
|
|
951
|
+
singleWindow: !0,
|
|
952
|
+
...F
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
id: "notepad",
|
|
956
|
+
name: "Notepad",
|
|
957
|
+
icon: "📝",
|
|
958
|
+
fcIcon: "FcEditImage",
|
|
959
|
+
...F
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
id: "image-viewer",
|
|
963
|
+
name: "Image Viewer",
|
|
964
|
+
icon: "🖼️",
|
|
965
|
+
fcIcon: "FcPicture",
|
|
966
|
+
defaultWidth: 700,
|
|
967
|
+
defaultHeight: 520,
|
|
968
|
+
minWidth: 640,
|
|
969
|
+
minHeight: 480
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
id: "pdf",
|
|
973
|
+
name: "PDF Viewer",
|
|
974
|
+
icon: "📄",
|
|
975
|
+
fcIcon: "FcDocument",
|
|
976
|
+
defaultWidth: 780,
|
|
977
|
+
defaultHeight: 580,
|
|
978
|
+
minWidth: 640,
|
|
979
|
+
minHeight: 480
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
id: "uploader",
|
|
983
|
+
name: "Uploader",
|
|
984
|
+
icon: "📤",
|
|
985
|
+
fcIcon: "FcUpload",
|
|
986
|
+
...F
|
|
987
|
+
},
|
|
988
|
+
{
|
|
989
|
+
id: "menuedit",
|
|
990
|
+
name: "MenuEdit",
|
|
991
|
+
icon: "📁",
|
|
992
|
+
fcIcon: "FcFolder",
|
|
993
|
+
singleWindow: !0,
|
|
994
|
+
...F
|
|
995
|
+
},
|
|
996
|
+
{
|
|
997
|
+
id: "device-info",
|
|
998
|
+
name: "Device Info",
|
|
999
|
+
icon: "📊",
|
|
1000
|
+
fcIcon: "FcBarChart",
|
|
1001
|
+
defaultWidth: 300,
|
|
1002
|
+
defaultHeight: 400,
|
|
1003
|
+
minWidth: 280,
|
|
1004
|
+
minHeight: 350,
|
|
1005
|
+
canMaximize: !1,
|
|
1006
|
+
alwaysOnTop: !0,
|
|
1007
|
+
singleWindow: !0
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
id: "calendar",
|
|
1011
|
+
name: "Calendar",
|
|
1012
|
+
icon: "📅",
|
|
1013
|
+
fcIcon: "FcCalendar",
|
|
1014
|
+
defaultWidth: 320,
|
|
1015
|
+
defaultHeight: 370,
|
|
1016
|
+
minWidth: !1,
|
|
1017
|
+
minHeight: !1,
|
|
1018
|
+
canMaximize: !1,
|
|
1019
|
+
singleWindow: !0
|
|
1020
|
+
}
|
|
1021
|
+
], we = I.map((e) => e.id), L = [
|
|
1022
|
+
{
|
|
1023
|
+
id: "welcome",
|
|
1024
|
+
name: "Welcome",
|
|
1025
|
+
icon: "👋",
|
|
1026
|
+
fcIcon: "FcBusinessContact",
|
|
1027
|
+
defaultWidth: 900,
|
|
1028
|
+
defaultHeight: 700,
|
|
1029
|
+
minWidth: 600,
|
|
1030
|
+
minHeight: 500
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
id: "storybook",
|
|
1034
|
+
name: "Storybook",
|
|
1035
|
+
icon: "📖",
|
|
1036
|
+
fcIcon: "FcReading",
|
|
1037
|
+
defaultWidth: 1100,
|
|
1038
|
+
defaultHeight: 700,
|
|
1039
|
+
minWidth: 640,
|
|
1040
|
+
minHeight: 480
|
|
1041
|
+
},
|
|
1042
|
+
{
|
|
1043
|
+
id: "linkedin",
|
|
1044
|
+
name: "LinkedinApp",
|
|
1045
|
+
icon: "🔗",
|
|
1046
|
+
fcIcon: "FiLinkedin",
|
|
1047
|
+
iconColor: "#0A66C2",
|
|
1048
|
+
defaultWidth: 1100,
|
|
1049
|
+
defaultHeight: 700
|
|
1050
|
+
},
|
|
1051
|
+
{
|
|
1052
|
+
id: "github",
|
|
1053
|
+
name: "GithubApp",
|
|
1054
|
+
icon: "🔗",
|
|
1055
|
+
fcIcon: "FiGithub",
|
|
1056
|
+
iconColor: "#000",
|
|
1057
|
+
defaultWidth: 640,
|
|
1058
|
+
defaultHeight: 480
|
|
1059
|
+
},
|
|
1060
|
+
{
|
|
1061
|
+
id: "terminal",
|
|
1062
|
+
name: "Terminal",
|
|
1063
|
+
icon: "💻",
|
|
1064
|
+
fcIcon: "FcCommandLine",
|
|
1065
|
+
...F
|
|
1066
|
+
},
|
|
1067
|
+
{
|
|
1068
|
+
id: "code-server",
|
|
1069
|
+
name: "VS Code",
|
|
1070
|
+
icon: "📘",
|
|
1071
|
+
fcIcon: "FcCodesandbox",
|
|
1072
|
+
iconUrl: "/vscode.svg",
|
|
1073
|
+
defaultWidth: 1200,
|
|
1074
|
+
defaultHeight: 800,
|
|
1075
|
+
minWidth: 800,
|
|
1076
|
+
minHeight: 600
|
|
1077
|
+
},
|
|
1078
|
+
{
|
|
1079
|
+
id: "dos-emulator",
|
|
1080
|
+
name: "DOS Emulator",
|
|
1081
|
+
icon: "🎮",
|
|
1082
|
+
fcIcon: "FcGamepad",
|
|
1083
|
+
defaultWidth: 900,
|
|
1084
|
+
defaultHeight: 700,
|
|
1085
|
+
minWidth: 640,
|
|
1086
|
+
minHeight: 480
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
id: "doom",
|
|
1090
|
+
name: "DOOM",
|
|
1091
|
+
icon: "🔫",
|
|
1092
|
+
fcIcon: "FcVideoGame",
|
|
1093
|
+
iconUrl: "doom.png",
|
|
1094
|
+
defaultWidth: 900,
|
|
1095
|
+
defaultHeight: 700,
|
|
1096
|
+
minWidth: 640,
|
|
1097
|
+
minHeight: 480,
|
|
1098
|
+
autoLoad: {
|
|
1099
|
+
url: "Games/doom.jsdos",
|
|
1100
|
+
name: "DOOM"
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
], Te = L.map((e) => e.id), R = [...I, ...L], z = [
|
|
1104
|
+
"welcome",
|
|
1105
|
+
"uploader",
|
|
1106
|
+
"terminal",
|
|
1107
|
+
"code-server",
|
|
1108
|
+
"storybook",
|
|
1109
|
+
"settings",
|
|
1110
|
+
"notepad",
|
|
1111
|
+
"linkedin",
|
|
1112
|
+
"github",
|
|
1113
|
+
"files",
|
|
1114
|
+
"doom"
|
|
1115
|
+
];
|
|
1116
|
+
function Ee(e) {
|
|
1117
|
+
for (let t of e) R.find((e) => e.id === t.id) || R.push(t);
|
|
1118
|
+
}
|
|
1119
|
+
function De(e) {
|
|
1120
|
+
for (let t of e) z.includes(t) || z.push(t);
|
|
1121
|
+
}
|
|
1122
|
+
//#endregion
|
|
1123
|
+
//#region src/utils/getAppIdForMime.ts
|
|
1124
|
+
var B = [], V = (e) => {
|
|
1125
|
+
B.push(e);
|
|
1126
|
+
}, Oe = new Set([
|
|
1127
|
+
"image/jpeg",
|
|
1128
|
+
"image/png",
|
|
1129
|
+
"image/gif",
|
|
1130
|
+
"image/svg+xml",
|
|
1131
|
+
"image/webp",
|
|
1132
|
+
"image/bmp"
|
|
1133
|
+
]), H = new Set([
|
|
1134
|
+
"text/plain",
|
|
1135
|
+
"text/markdown",
|
|
1136
|
+
"text/x-markdown",
|
|
1137
|
+
"application/json"
|
|
1138
|
+
]);
|
|
1139
|
+
V({
|
|
1140
|
+
appId: "pdf",
|
|
1141
|
+
mimeTypes: ["application/pdf"],
|
|
1142
|
+
transformContentData: (e) => ({ src: e.url ?? e.name })
|
|
1143
|
+
}), V({
|
|
1144
|
+
appId: "image-viewer",
|
|
1145
|
+
mimeTypes: (e) => Oe.has(e) || e.startsWith("image/"),
|
|
1146
|
+
transformContentData: (e) => ({ src: e.url ?? e.name })
|
|
1147
|
+
}), V({
|
|
1148
|
+
appId: "notepad",
|
|
1149
|
+
mimeTypes: (e) => H.has(e) || e.startsWith("text/"),
|
|
1150
|
+
transformContentData: (e) => ({
|
|
1151
|
+
url: e.url,
|
|
1152
|
+
initialName: e.name,
|
|
1153
|
+
fileId: e.id
|
|
1154
|
+
})
|
|
1155
|
+
}), V({
|
|
1156
|
+
appId: "dos-emulator",
|
|
1157
|
+
mimeTypes: [
|
|
1158
|
+
"application/jsdos",
|
|
1159
|
+
"application/zip",
|
|
1160
|
+
"application/x-zip-compressed"
|
|
1161
|
+
],
|
|
1162
|
+
transformContentData: (e) => ({ autoLoad: {
|
|
1163
|
+
url: e.url ?? e.name,
|
|
1164
|
+
name: e.name
|
|
1165
|
+
} })
|
|
1166
|
+
});
|
|
1167
|
+
function ke(e) {
|
|
1168
|
+
if (!e) return null;
|
|
1169
|
+
for (let t of B) if (typeof t.mimeTypes == "function" ? t.mimeTypes(e) : t.mimeTypes.includes(e)) return t;
|
|
1170
|
+
return null;
|
|
1171
|
+
}
|
|
1172
|
+
function U(e) {
|
|
1173
|
+
if (typeof e == "string" || e === void 0) return ke(e)?.appId ?? "files";
|
|
1174
|
+
let t = ke(e.mimeType);
|
|
1175
|
+
return t ? {
|
|
1176
|
+
appId: t.appId,
|
|
1177
|
+
contentData: t.transformContentData(e)
|
|
1178
|
+
} : null;
|
|
1179
|
+
}
|
|
1180
|
+
//#endregion
|
|
1181
|
+
//#region src/stores/customAppStore.ts
|
|
1182
|
+
var W = {
|
|
1183
|
+
isLoaded: !1,
|
|
1184
|
+
isLoading: !1,
|
|
1185
|
+
isReady: !1,
|
|
1186
|
+
hasError: !1,
|
|
1187
|
+
error: void 0,
|
|
1188
|
+
mountedAt: 0,
|
|
1189
|
+
instance: void 0
|
|
1190
|
+
}, G = n((e) => ({
|
|
1191
|
+
mountedApps: {},
|
|
1192
|
+
registeredApps: {},
|
|
1193
|
+
hmrConnected: !1,
|
|
1194
|
+
hmrError: null,
|
|
1195
|
+
devServerOffline: !1,
|
|
1196
|
+
hmrRetryCount: 0,
|
|
1197
|
+
setAppLoading: (t) => e((e) => ({ mountedApps: {
|
|
1198
|
+
...e.mountedApps,
|
|
1199
|
+
[t]: {
|
|
1200
|
+
...W,
|
|
1201
|
+
isLoading: !0,
|
|
1202
|
+
mountedAt: Date.now()
|
|
1203
|
+
}
|
|
1204
|
+
} })),
|
|
1205
|
+
setAppLoaded: (t) => e((e) => ({ mountedApps: {
|
|
1206
|
+
...e.mountedApps,
|
|
1207
|
+
[t]: {
|
|
1208
|
+
...e.mountedApps[t] || W,
|
|
1209
|
+
isLoaded: !0,
|
|
1210
|
+
isLoading: !1,
|
|
1211
|
+
hasError: !1,
|
|
1212
|
+
error: void 0
|
|
1213
|
+
}
|
|
1214
|
+
} })),
|
|
1215
|
+
setAppReady: (t, n) => e((e) => ({ mountedApps: {
|
|
1216
|
+
...e.mountedApps,
|
|
1217
|
+
[t]: {
|
|
1218
|
+
...e.mountedApps[t] || W,
|
|
1219
|
+
isReady: !0,
|
|
1220
|
+
isLoaded: !0,
|
|
1221
|
+
isLoading: !1,
|
|
1222
|
+
instance: n ?? e.mountedApps[t]?.instance
|
|
1223
|
+
}
|
|
1224
|
+
} })),
|
|
1225
|
+
setAppError: (t, n) => e((e) => ({ mountedApps: {
|
|
1226
|
+
...e.mountedApps,
|
|
1227
|
+
[t]: {
|
|
1228
|
+
...e.mountedApps[t] || W,
|
|
1229
|
+
isLoaded: !1,
|
|
1230
|
+
isLoading: !1,
|
|
1231
|
+
isReady: !1,
|
|
1232
|
+
hasError: !0,
|
|
1233
|
+
error: n
|
|
1234
|
+
}
|
|
1235
|
+
} })),
|
|
1236
|
+
clearApp: (t) => e((e) => {
|
|
1237
|
+
let { [t]: n, ...r } = e.mountedApps;
|
|
1238
|
+
return { mountedApps: r };
|
|
1239
|
+
}),
|
|
1240
|
+
registerApp: (t) => e((e) => ({ registeredApps: {
|
|
1241
|
+
...e.registeredApps,
|
|
1242
|
+
[t.id]: t
|
|
1243
|
+
} })),
|
|
1244
|
+
unregisterApp: (t) => e((e) => {
|
|
1245
|
+
let { [t]: n, ...r } = e.registeredApps;
|
|
1246
|
+
return { registeredApps: r };
|
|
1247
|
+
}),
|
|
1248
|
+
setHmrConnected: (t) => e({
|
|
1249
|
+
hmrConnected: t,
|
|
1250
|
+
devServerOffline: !t
|
|
1251
|
+
}),
|
|
1252
|
+
setHmrError: (t) => e({ hmrError: t }),
|
|
1253
|
+
setDevServerOffline: (t) => e({ devServerOffline: t }),
|
|
1254
|
+
incrementHmrRetry: () => e((e) => ({ hmrRetryCount: e.hmrRetryCount + 1 })),
|
|
1255
|
+
resetHmrRetry: () => e({ hmrRetryCount: 0 })
|
|
1256
|
+
})), Ae = "/", K = null, q = null;
|
|
1257
|
+
function je(e) {
|
|
1258
|
+
q = e, K = null;
|
|
1259
|
+
}
|
|
1260
|
+
function Me() {
|
|
1261
|
+
if (K !== null) return K;
|
|
1262
|
+
if (q !== null) return K = q, K;
|
|
1263
|
+
let e = document.querySelector("base[href]");
|
|
1264
|
+
if (e) {
|
|
1265
|
+
let t = e.getAttribute("href");
|
|
1266
|
+
if (t) return K = t, t;
|
|
1267
|
+
}
|
|
1268
|
+
return K = Ae, K;
|
|
1269
|
+
}
|
|
1270
|
+
function Ne() {
|
|
1271
|
+
K = null;
|
|
1272
|
+
}
|
|
1273
|
+
function Pe(e) {
|
|
1274
|
+
if (!e || e.startsWith("http://") || e.startsWith("https://") || e.startsWith("idb://") || e.startsWith("blob:") || e.startsWith("/")) return e;
|
|
1275
|
+
let t = Me();
|
|
1276
|
+
return (t.endsWith("/") ? t : `${t}/`) + e;
|
|
1277
|
+
}
|
|
1278
|
+
//#endregion
|
|
1279
|
+
//#region src/constants/breakpoints.ts
|
|
1280
|
+
var Fe = {
|
|
1281
|
+
MOBILE: 768,
|
|
1282
|
+
TABLET: 1024,
|
|
1283
|
+
DESKTOP: 1280
|
|
1284
|
+
}, Ie = {
|
|
1285
|
+
WIDTH: 1280,
|
|
1286
|
+
HEIGHT: 800
|
|
1287
|
+
}, Le = 48, Re = 80, ze = 80, Be = 20, Ve = Ie.WIDTH, He = Ie.HEIGHT, Ue = async () => {
|
|
1288
|
+
let e = await fetch(Pe("fs-manifest.json")), t = e.headers.get("content-type")?.includes("application/json");
|
|
1289
|
+
return e.ok && t ? await e.json() : null;
|
|
1290
|
+
}, J = new te();
|
|
1291
|
+
function We() {
|
|
1292
|
+
return e() ? (console.log("[FileSystem] Using DockerFileSystemAdapter"), new de()) : (console.log("[FileSystem] Using IndexedDBFileSystem"), new oe());
|
|
1293
|
+
}
|
|
1294
|
+
var Y = We(), Ge = () => {
|
|
1295
|
+
Y.clearAll().catch(() => {});
|
|
1296
|
+
}, Ke = () => J.reset();
|
|
1297
|
+
async function qe(e, t) {
|
|
1298
|
+
if (e.startsWith("idb://")) {
|
|
1299
|
+
let t = await Y.getBlob(e);
|
|
1300
|
+
return t ? t.text() : "";
|
|
1301
|
+
}
|
|
1302
|
+
let n = e.startsWith("http") || e.startsWith("/") ? e : `/${e}`, r = await fetch(n, { signal: t });
|
|
1303
|
+
return r.ok ? r.text() : "";
|
|
1304
|
+
}
|
|
1305
|
+
var X = () => Y.getRootNodes().find((e) => e.type === "folder" && e.name === "Desktop")?.id ?? null, Je = (e, t) => {
|
|
1306
|
+
let n = new Set(e.map((e) => `${e.x},${e.y}`)), r = Math.max(1, Math.floor((t - 20) / 80));
|
|
1307
|
+
for (let e = 0;; e++) {
|
|
1308
|
+
let t = 20 + e * 80;
|
|
1309
|
+
for (let e = 0; e < r; e++) {
|
|
1310
|
+
let r = 20 + e * 80;
|
|
1311
|
+
if (!n.has(`${t},${r}`)) return {
|
|
1312
|
+
x: t,
|
|
1313
|
+
y: r
|
|
1314
|
+
};
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
}, Ye = (e, t) => {
|
|
1318
|
+
let n = Math.max(1, Math.floor((t - 20) / 80)), r = Math.floor(e / n), i = e % n;
|
|
1319
|
+
return {
|
|
1320
|
+
x: 20 + r * 80,
|
|
1321
|
+
y: 20 + i * 80
|
|
1322
|
+
};
|
|
1323
|
+
}, Z = (e, t, n) => {
|
|
1324
|
+
let r = Je(e, n);
|
|
1325
|
+
return [...e, l({
|
|
1326
|
+
...t,
|
|
1327
|
+
...r
|
|
1328
|
+
})];
|
|
1329
|
+
}, Q = () => {
|
|
1330
|
+
let e = X();
|
|
1331
|
+
if (!e || !Y.isReady()) return;
|
|
1332
|
+
let t = Y.getChildren(e), n = new Set(t.map((e) => e.id)), r = new Set(t.map((e) => e.name)), { icons: i, viewportHeight: a } = $.getState(), o = i.filter((e) => !e.nodeId || n.has(e.nodeId) || r.has(e.name));
|
|
1333
|
+
for (let e of t) {
|
|
1334
|
+
let t = o.find((t) => t.name === e.name);
|
|
1335
|
+
if (t) t.nodeId !== e.id && (o = o.map((t) => t.name === e.name ? {
|
|
1336
|
+
...t,
|
|
1337
|
+
nodeId: e.id
|
|
1338
|
+
} : t));
|
|
1339
|
+
else {
|
|
1340
|
+
let t = e.type === "folder", n = t ? e : null, r = t ? null : e, i = t ? "files" : r ? U(r)?.appId ?? "" : "";
|
|
1341
|
+
o = Z(o, {
|
|
1342
|
+
name: e.name,
|
|
1343
|
+
icon: t ? "📁" : "📄",
|
|
1344
|
+
iconName: n?.iconName,
|
|
1345
|
+
iconColor: n?.iconColor,
|
|
1346
|
+
appId: i,
|
|
1347
|
+
nodeId: e.id
|
|
1348
|
+
}, a);
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
let s = N(o);
|
|
1352
|
+
$.setState({ icons: s.map((e, t) => ({
|
|
1353
|
+
...e,
|
|
1354
|
+
...Ye(t, a)
|
|
1355
|
+
})) });
|
|
1356
|
+
}, $ = n()(i((e, n) => ({
|
|
1357
|
+
windows: [],
|
|
1358
|
+
openWindow: (t) => {
|
|
1359
|
+
let n = J.open(t);
|
|
1360
|
+
e((e) => ({ windows: [...e.windows, n] }));
|
|
1361
|
+
},
|
|
1362
|
+
closeWindow: (t) => {
|
|
1363
|
+
J.close(t), e((e) => ({ windows: e.windows.filter((e) => e.id !== t) }));
|
|
1364
|
+
},
|
|
1365
|
+
minimizeWindow: (t) => {
|
|
1366
|
+
J.minimize(t), e((e) => ({ windows: e.windows.map((e) => e.id === t ? {
|
|
1367
|
+
...e,
|
|
1368
|
+
state: "minimized"
|
|
1369
|
+
} : e) }));
|
|
1370
|
+
},
|
|
1371
|
+
maximizeWindow: (t) => {
|
|
1372
|
+
J.maximize(t), e((e) => ({ windows: e.windows.map((e) => e.id === t ? {
|
|
1373
|
+
...e,
|
|
1374
|
+
state: "maximized"
|
|
1375
|
+
} : e) }));
|
|
1376
|
+
},
|
|
1377
|
+
restoreWindow: (t) => {
|
|
1378
|
+
J.restore(t), e((e) => ({ windows: e.windows.map((e) => e.id === t ? {
|
|
1379
|
+
...e,
|
|
1380
|
+
state: "normal"
|
|
1381
|
+
} : e) }));
|
|
1382
|
+
},
|
|
1383
|
+
focusWindow: (t) => {
|
|
1384
|
+
J.focus(t);
|
|
1385
|
+
let n = J.getById(t);
|
|
1386
|
+
n && e((e) => ({ windows: e.windows.map((e) => e.id === t ? n : e) }));
|
|
1387
|
+
},
|
|
1388
|
+
moveWindow: (t, n, r) => {
|
|
1389
|
+
J.move(t, n, r), e((e) => ({ windows: e.windows.map((e) => e.id === t ? {
|
|
1390
|
+
...e,
|
|
1391
|
+
x: n,
|
|
1392
|
+
y: r
|
|
1393
|
+
} : e) }));
|
|
1394
|
+
},
|
|
1395
|
+
resizeWindow: (t, n, r) => {
|
|
1396
|
+
J.resize(t, n, r), e((e) => ({ windows: e.windows.map((e) => e.id === t ? {
|
|
1397
|
+
...e,
|
|
1398
|
+
width: n,
|
|
1399
|
+
height: r
|
|
1400
|
+
} : e) }));
|
|
1401
|
+
},
|
|
1402
|
+
icons: [],
|
|
1403
|
+
addIcon: (t) => {
|
|
1404
|
+
let n = l(t);
|
|
1405
|
+
e((e) => ({ icons: [...e.icons, n] }));
|
|
1406
|
+
},
|
|
1407
|
+
removeIcon: (t) => {
|
|
1408
|
+
e((e) => ({ icons: e.icons.filter((e) => e.id !== t) }));
|
|
1409
|
+
},
|
|
1410
|
+
fsNodes: [],
|
|
1411
|
+
desktopFolderId: null,
|
|
1412
|
+
isFsReady: !1,
|
|
1413
|
+
initFs: async () => {
|
|
1414
|
+
try {
|
|
1415
|
+
Y.isReady() && Y.reinitialize ? await Y.reinitialize() : Y.isReady() || await Y.initialize();
|
|
1416
|
+
let r = await Ue();
|
|
1417
|
+
if (r) {
|
|
1418
|
+
let e = r.sha ?? null, t = await Y.getManifestSha();
|
|
1419
|
+
Y.isEmpty() ? (await Y.seed(r), e && await Y.saveManifestSha(e)) : t !== e && e !== null && (await Y.mergeSeed(r), await Y.saveManifestSha(e));
|
|
1420
|
+
}
|
|
1421
|
+
if (e({
|
|
1422
|
+
fsNodes: Y.getAllNodes(),
|
|
1423
|
+
desktopFolderId: X(),
|
|
1424
|
+
isFsReady: !0
|
|
1425
|
+
}), !t()) {
|
|
1426
|
+
let t = null;
|
|
1427
|
+
try {
|
|
1428
|
+
if (t = await O(), t?.apps?.length) {
|
|
1429
|
+
e({ customApps: t.apps });
|
|
1430
|
+
for (let e of t.apps) G.getState().registerApp(e);
|
|
1431
|
+
}
|
|
1432
|
+
let r = new Set(t?.apps?.map((e) => e.id) ?? []), i = n().icons.filter((e) => e.appId && !R.find((t) => t.id === e.appId) && !r.has(e.appId)).map((e) => e.appId);
|
|
1433
|
+
i.length > 0 && e((e) => ({
|
|
1434
|
+
icons: e.icons.filter((e) => !i.includes(e.appId)),
|
|
1435
|
+
customApps: e.customApps.filter((e) => !i.includes(e.id))
|
|
1436
|
+
}));
|
|
1437
|
+
} catch (e) {
|
|
1438
|
+
console.warn("[DesktopStore] Failed to load custom apps manifest:", e);
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
for (let t of z) {
|
|
1442
|
+
let r = R.find((e) => e.id === t);
|
|
1443
|
+
r && (n().icons.some((e) => e.appId === t) || e({ icons: Z(n().icons, {
|
|
1444
|
+
name: r.name,
|
|
1445
|
+
icon: r.icon,
|
|
1446
|
+
appId: t
|
|
1447
|
+
}, n().viewportHeight) }));
|
|
1448
|
+
}
|
|
1449
|
+
if (!t()) {
|
|
1450
|
+
let t = n().customApps;
|
|
1451
|
+
if (t.length) for (let r of t) n().icons.some((e) => e.appId === r.id) || e({ icons: Z(n().icons, {
|
|
1452
|
+
name: r.name,
|
|
1453
|
+
icon: r.icon,
|
|
1454
|
+
appId: r.id
|
|
1455
|
+
}, n().viewportHeight) });
|
|
1456
|
+
}
|
|
1457
|
+
let i = X();
|
|
1458
|
+
if (!i) return;
|
|
1459
|
+
Y.getChildren(i).forEach((t) => {
|
|
1460
|
+
if (t.type !== "file") return;
|
|
1461
|
+
let r = n().icons.find((e) => e.name === t.name);
|
|
1462
|
+
r ? r.nodeId || e({ icons: n().icons.map((e) => e.name === t.name ? {
|
|
1463
|
+
...e,
|
|
1464
|
+
nodeId: t.id
|
|
1465
|
+
} : e) }) : e({ icons: Z(n().icons, {
|
|
1466
|
+
name: t.name,
|
|
1467
|
+
icon: "📄",
|
|
1468
|
+
appId: U(t.mimeType),
|
|
1469
|
+
nodeId: t.id
|
|
1470
|
+
}, n().viewportHeight) });
|
|
1471
|
+
}), Q();
|
|
1472
|
+
} catch (t) {
|
|
1473
|
+
console.error("Failed to initialize filesystem:", t), e({ isFsReady: !0 });
|
|
1474
|
+
}
|
|
1475
|
+
},
|
|
1476
|
+
createFile: async (t, r, i, a) => {
|
|
1477
|
+
let o = await Y.createFile(t, r, i, a), s = X(), { icons: c, viewportHeight: l } = n(), u = i && i === s && !c.some((e) => e.name === o.name) ? Z(c, {
|
|
1478
|
+
name: o.name,
|
|
1479
|
+
icon: "📄",
|
|
1480
|
+
appId: U(o.mimeType),
|
|
1481
|
+
nodeId: o.id
|
|
1482
|
+
}, l) : c;
|
|
1483
|
+
return e({
|
|
1484
|
+
fsNodes: Y.getAllNodes(),
|
|
1485
|
+
icons: u
|
|
1486
|
+
}), o;
|
|
1487
|
+
},
|
|
1488
|
+
createFolder: async (t, r, i, a) => {
|
|
1489
|
+
let o = await Y.createFolder(t, r, i, a), s = X(), { icons: c, viewportHeight: l } = n(), u = r && r === s && !c.some((e) => e.name === o.name) ? Z(c, {
|
|
1490
|
+
name: o.name,
|
|
1491
|
+
icon: "📁",
|
|
1492
|
+
iconName: o.iconName,
|
|
1493
|
+
iconColor: o.iconColor,
|
|
1494
|
+
appId: "files",
|
|
1495
|
+
nodeId: o.id
|
|
1496
|
+
}, l) : c;
|
|
1497
|
+
return e({
|
|
1498
|
+
fsNodes: Y.getAllNodes(),
|
|
1499
|
+
icons: u
|
|
1500
|
+
}), o;
|
|
1501
|
+
},
|
|
1502
|
+
updateFile: async (t, n) => {
|
|
1503
|
+
await Y.updateFile(t, n), e({ fsNodes: Y.getAllNodes() });
|
|
1504
|
+
},
|
|
1505
|
+
deleteNode: async (t) => {
|
|
1506
|
+
let n = Y.getNode(t);
|
|
1507
|
+
if (await Y.delete(t), e({ fsNodes: Y.getAllNodes() }), n?.type === "file" || n?.type === "folder") {
|
|
1508
|
+
let t = X();
|
|
1509
|
+
n.parentId && n.parentId === t && e((e) => ({ icons: e.icons.filter((e) => e.name !== n.name) }));
|
|
1510
|
+
}
|
|
1511
|
+
},
|
|
1512
|
+
moveNode: async (t, n) => {
|
|
1513
|
+
await Y.move(t, n), e({ fsNodes: Y.getAllNodes() });
|
|
1514
|
+
},
|
|
1515
|
+
setFsNodes: (t) => {
|
|
1516
|
+
e({ fsNodes: t });
|
|
1517
|
+
},
|
|
1518
|
+
syncIcons: () => {
|
|
1519
|
+
Q();
|
|
1520
|
+
},
|
|
1521
|
+
clipboard: {
|
|
1522
|
+
content: [],
|
|
1523
|
+
action: null
|
|
1524
|
+
},
|
|
1525
|
+
copyToClipboard: (t) => {
|
|
1526
|
+
e({ clipboard: {
|
|
1527
|
+
content: t,
|
|
1528
|
+
action: "copy"
|
|
1529
|
+
} });
|
|
1530
|
+
},
|
|
1531
|
+
cutToClipboard: (t) => {
|
|
1532
|
+
e({ clipboard: {
|
|
1533
|
+
content: t,
|
|
1534
|
+
action: "cut"
|
|
1535
|
+
} });
|
|
1536
|
+
},
|
|
1537
|
+
clearClipboard: () => {
|
|
1538
|
+
e({ clipboard: {
|
|
1539
|
+
content: [],
|
|
1540
|
+
action: null
|
|
1541
|
+
} });
|
|
1542
|
+
},
|
|
1543
|
+
filesCurrentFolderId: null,
|
|
1544
|
+
setFilesCurrentFolderId: (t) => {
|
|
1545
|
+
e({ filesCurrentFolderId: t });
|
|
1546
|
+
},
|
|
1547
|
+
contextMenu: {
|
|
1548
|
+
x: 0,
|
|
1549
|
+
y: 0,
|
|
1550
|
+
owner: null
|
|
1551
|
+
},
|
|
1552
|
+
openContextMenu: (t, n, r, i) => {
|
|
1553
|
+
e({ contextMenu: {
|
|
1554
|
+
x: t,
|
|
1555
|
+
y: n,
|
|
1556
|
+
owner: r,
|
|
1557
|
+
targetNodeId: i
|
|
1558
|
+
} });
|
|
1559
|
+
},
|
|
1560
|
+
closeContextMenu: () => {
|
|
1561
|
+
e({ contextMenu: {
|
|
1562
|
+
x: 0,
|
|
1563
|
+
y: 0,
|
|
1564
|
+
owner: null,
|
|
1565
|
+
targetNodeId: void 0
|
|
1566
|
+
} });
|
|
1567
|
+
},
|
|
1568
|
+
mergeSeed: async (t) => {
|
|
1569
|
+
await Y.mergeSeed(t), e({
|
|
1570
|
+
fsNodes: Y.getAllNodes(),
|
|
1571
|
+
desktopFolderId: X()
|
|
1572
|
+
});
|
|
1573
|
+
},
|
|
1574
|
+
mergeDesktopApps: (t) => {
|
|
1575
|
+
for (let r of t) {
|
|
1576
|
+
let t = R.find((e) => e.id === r);
|
|
1577
|
+
t && (n().icons.some((e) => e.appId === r) || e({ icons: Z(n().icons, {
|
|
1578
|
+
name: t.name,
|
|
1579
|
+
icon: t.icon,
|
|
1580
|
+
appId: r
|
|
1581
|
+
}, n().viewportHeight) }));
|
|
1582
|
+
}
|
|
1583
|
+
let r = X();
|
|
1584
|
+
if (r) for (let t of Y.getChildren(r)) t.type === "file" && (n().icons.some((e) => e.name === t.name) || e({ icons: Z(n().icons, {
|
|
1585
|
+
name: t.name,
|
|
1586
|
+
icon: "📄",
|
|
1587
|
+
appId: U(t.mimeType),
|
|
1588
|
+
nodeId: t.id
|
|
1589
|
+
}, n().viewportHeight) }));
|
|
1590
|
+
},
|
|
1591
|
+
reorderDesktopApps: (t) => {
|
|
1592
|
+
let r = n().icons, i = [], a = [];
|
|
1593
|
+
for (let e of r) e.appId && !e.nodeId ? i.push(e) : a.push(e);
|
|
1594
|
+
let o = [];
|
|
1595
|
+
for (let e of t) {
|
|
1596
|
+
let t = i.findIndex((t) => t.appId === e);
|
|
1597
|
+
t !== -1 && o.push(i[t]);
|
|
1598
|
+
}
|
|
1599
|
+
for (let e of i) o.includes(e) || o.push(e);
|
|
1600
|
+
let s = 20, c = 20, l = n().viewportHeight, u = Math.max(1, Math.floor((l - 48 - 20) / 80));
|
|
1601
|
+
for (let e = 0; e < o.length; e++) {
|
|
1602
|
+
let t = Math.floor(e / 1);
|
|
1603
|
+
t >= u && t > 0 && (c += 80, s = 20), o[e] = {
|
|
1604
|
+
...o[e],
|
|
1605
|
+
x: c,
|
|
1606
|
+
y: s
|
|
1607
|
+
}, s += 80;
|
|
1608
|
+
}
|
|
1609
|
+
e({ icons: [...o, ...a] });
|
|
1610
|
+
},
|
|
1611
|
+
notifications: [],
|
|
1612
|
+
addNotification: (t) => {
|
|
1613
|
+
e((e) => ({ notifications: [...e.notifications, t] }));
|
|
1614
|
+
},
|
|
1615
|
+
removeNotification: (t) => {
|
|
1616
|
+
e((e) => ({ notifications: e.notifications.filter((e) => e.id !== t) }));
|
|
1617
|
+
},
|
|
1618
|
+
viewportWidth: Ve,
|
|
1619
|
+
viewportHeight: He,
|
|
1620
|
+
isViewportInitialized: !1,
|
|
1621
|
+
setViewportSize: (t, r) => {
|
|
1622
|
+
let i = n().viewportWidth, a = n().viewportHeight, o = n().isViewportInitialized;
|
|
1623
|
+
if (i === t && a === r) return;
|
|
1624
|
+
if (e({
|
|
1625
|
+
viewportWidth: t,
|
|
1626
|
+
viewportHeight: r
|
|
1627
|
+
}), !o) {
|
|
1628
|
+
e({ isViewportInitialized: !0 });
|
|
1629
|
+
return;
|
|
1630
|
+
}
|
|
1631
|
+
if (a !== r) {
|
|
1632
|
+
let t = Math.max(1, Math.floor((a - 20) / 80)), i = Math.max(1, Math.floor((r - 20) / 80));
|
|
1633
|
+
t !== i && e({ icons: n().icons.map((e, t) => {
|
|
1634
|
+
let n = Math.floor(t / i), r = t % i;
|
|
1635
|
+
return {
|
|
1636
|
+
...e,
|
|
1637
|
+
x: 20 + n * 80,
|
|
1638
|
+
y: 20 + r * 80
|
|
1639
|
+
};
|
|
1640
|
+
}) });
|
|
1641
|
+
}
|
|
1642
|
+
let s = t < 768, c = n().windows.map((e) => {
|
|
1643
|
+
if (e.state !== "normal") return e;
|
|
1644
|
+
if (s) return {
|
|
1645
|
+
...e,
|
|
1646
|
+
x: 0,
|
|
1647
|
+
y: 0,
|
|
1648
|
+
width: t,
|
|
1649
|
+
height: r,
|
|
1650
|
+
minWidth: void 0,
|
|
1651
|
+
minHeight: void 0
|
|
1652
|
+
};
|
|
1653
|
+
let n = i > 0 ? t / i : 1, o = a > 0 ? r / a : 1, c = Math.round(e.x * n), l = Math.round(e.y * o), u = e.width, d = e.height;
|
|
1654
|
+
return u > t && (u = t), d > r && (d = r), c = Math.max(0, Math.min(c, t - Math.min(u, 100))), l = Math.max(0, Math.min(l, r - Math.min(d, 40))), {
|
|
1655
|
+
...e,
|
|
1656
|
+
x: c,
|
|
1657
|
+
y: l,
|
|
1658
|
+
width: u,
|
|
1659
|
+
height: d
|
|
1660
|
+
};
|
|
1661
|
+
});
|
|
1662
|
+
for (let e of c) J.move(e.id, e.x, e.y), J.resize(e.id, e.width, e.height);
|
|
1663
|
+
e({ windows: c });
|
|
1664
|
+
},
|
|
1665
|
+
desktopSortMode: "default",
|
|
1666
|
+
filesSortMode: "default",
|
|
1667
|
+
setDesktopSortMode: (t) => {
|
|
1668
|
+
e({ desktopSortMode: t });
|
|
1669
|
+
let r = n().icons, i = P(r, t), a = n().viewportHeight;
|
|
1670
|
+
e({ icons: i.map((e, t) => ({
|
|
1671
|
+
...e,
|
|
1672
|
+
...Ye(t, a)
|
|
1673
|
+
})) });
|
|
1674
|
+
},
|
|
1675
|
+
setFilesSortMode: (t) => {
|
|
1676
|
+
e({ filesSortMode: t });
|
|
1677
|
+
},
|
|
1678
|
+
launcherFolders: C,
|
|
1679
|
+
setLauncherFolders: (t) => {
|
|
1680
|
+
e({ launcherFolders: t });
|
|
1681
|
+
},
|
|
1682
|
+
createLauncherFolder: (t) => {
|
|
1683
|
+
let n = u(t);
|
|
1684
|
+
return e((e) => ({ launcherFolders: [...e.launcherFolders, n].sort((e, t) => e.order - t.order) })), n;
|
|
1685
|
+
},
|
|
1686
|
+
updateLauncherFolder: (t, n) => {
|
|
1687
|
+
e((e) => ({ launcherFolders: e.launcherFolders.map((e) => e.id === t ? f(e, n) : e) }));
|
|
1688
|
+
},
|
|
1689
|
+
deleteLauncherFolder: (t) => {
|
|
1690
|
+
e((e) => ({ launcherFolders: e.launcherFolders.filter((e) => e.id !== t || e.isPredefined) }));
|
|
1691
|
+
},
|
|
1692
|
+
moveLauncherFolder: (t, n) => {
|
|
1693
|
+
e((e) => ({ launcherFolders: e.launcherFolders.map((e) => e.id === t ? {
|
|
1694
|
+
...e,
|
|
1695
|
+
order: n
|
|
1696
|
+
} : e).sort((e, t) => e.order - t.order) }));
|
|
1697
|
+
},
|
|
1698
|
+
addAppToFolder: (t, n) => {
|
|
1699
|
+
e((e) => ({ launcherFolders: e.launcherFolders.map((e) => e.id === n && !e.appIds.includes(t) ? {
|
|
1700
|
+
...e,
|
|
1701
|
+
appIds: [...e.appIds, t]
|
|
1702
|
+
} : e) }));
|
|
1703
|
+
},
|
|
1704
|
+
removeAppFromFolder: (t, n) => {
|
|
1705
|
+
e((e) => ({ launcherFolders: e.launcherFolders.map((e) => e.id === n ? {
|
|
1706
|
+
...e,
|
|
1707
|
+
appIds: e.appIds.filter((e) => e !== t)
|
|
1708
|
+
} : e) }));
|
|
1709
|
+
},
|
|
1710
|
+
customApps: [],
|
|
1711
|
+
setCustomApps: (t) => {
|
|
1712
|
+
e({ customApps: t });
|
|
1713
|
+
},
|
|
1714
|
+
handleCustomAppRegistered: (t) => {
|
|
1715
|
+
e((e) => ({ customApps: e.customApps.some((e) => e.id === t.id) ? e.customApps.map((e) => e.id === t.id ? t : e) : [...e.customApps, t] })), n().icons.find((e) => e.appId === t.id) || e((e) => ({ icons: Z(e.icons, {
|
|
1716
|
+
name: t.name,
|
|
1717
|
+
icon: t.icon || "FcDataSheet",
|
|
1718
|
+
appId: t.id
|
|
1719
|
+
}, e.viewportHeight) }));
|
|
1720
|
+
},
|
|
1721
|
+
handleCustomAppUnregistered: (t) => {
|
|
1722
|
+
e((e) => ({ customApps: e.customApps.filter((e) => e.id !== t) })), e((e) => ({ icons: e.icons.filter((e) => e.appId !== t) })), n().windows.filter((e) => e.content === t).forEach((e) => n().closeWindow(e.id)), G.getState().clearApp(t);
|
|
1723
|
+
}
|
|
1724
|
+
}), {
|
|
1725
|
+
name: "fde-desktop",
|
|
1726
|
+
storage: r(() => localStorage),
|
|
1727
|
+
partialize: (e) => ({
|
|
1728
|
+
windows: e.windows,
|
|
1729
|
+
icons: e.icons,
|
|
1730
|
+
customApps: e.customApps,
|
|
1731
|
+
desktopSortMode: e.desktopSortMode,
|
|
1732
|
+
filesSortMode: e.filesSortMode,
|
|
1733
|
+
launcherFolders: e.launcherFolders,
|
|
1734
|
+
viewportWidth: e.viewportWidth,
|
|
1735
|
+
viewportHeight: e.viewportHeight
|
|
1736
|
+
}),
|
|
1737
|
+
merge: (e, t) => {
|
|
1738
|
+
let n = e, r = ["createItem"], i = (n.windows ?? []).filter((e) => !r.includes(e.content)).map((e) => {
|
|
1739
|
+
let r = R.find((t) => t.id === e.content), i = (n.customApps ?? t.customApps)?.find((t) => t.id === e.content);
|
|
1740
|
+
return {
|
|
1741
|
+
...e,
|
|
1742
|
+
icon: e.icon ?? r?.icon ?? i?.icon,
|
|
1743
|
+
fcIcon: e.fcIcon ?? r?.fcIcon,
|
|
1744
|
+
iconUrl: e.iconUrl ?? r?.iconUrl,
|
|
1745
|
+
iconColor: r?.iconColor,
|
|
1746
|
+
canMaximize: r?.canMaximize ?? i?.window?.canMaximize,
|
|
1747
|
+
minWidth: r?.minWidth === !1 || i?.window?.minWidth === !1 ? void 0 : r?.minWidth ?? i?.window?.minWidth ?? F.minWidth,
|
|
1748
|
+
minHeight: r?.minHeight === !1 || i?.window?.minHeight === !1 ? void 0 : r?.minHeight ?? i?.window?.minHeight ?? F.minHeight
|
|
1749
|
+
};
|
|
1750
|
+
});
|
|
1751
|
+
J.loadWindows(i);
|
|
1752
|
+
let a = new Set(C.map((e) => e.id)), o = (n.launcherFolders ?? []).filter((e) => !a.has(e.id)), s = [...C, ...o].sort((e, t) => e.order - t.order), c = n.viewportWidth != null && n.viewportHeight != null;
|
|
1753
|
+
return {
|
|
1754
|
+
...t,
|
|
1755
|
+
...n,
|
|
1756
|
+
windows: i,
|
|
1757
|
+
launcherFolders: s,
|
|
1758
|
+
viewportWidth: n.viewportWidth ?? t.viewportWidth,
|
|
1759
|
+
viewportHeight: n.viewportHeight ?? t.viewportHeight,
|
|
1760
|
+
isViewportInitialized: c ? !0 : t.isViewportInitialized
|
|
1761
|
+
};
|
|
1762
|
+
}
|
|
1763
|
+
}));
|
|
1764
|
+
typeof window < "u" && (window.__DESKTOP_STATE__ = $.getState(), $.subscribe((e) => {
|
|
1765
|
+
window.__DESKTOP_STATE__ = e;
|
|
1766
|
+
}));
|
|
1767
|
+
//#endregion
|
|
1768
|
+
export { oe as $, we as A, pe as B, R as C, L as D, De as E, A as F, he as G, ge as H, Ce as I, x as J, xe as K, k as L, Se as M, N, Te as O, P, ue as Q, ye as R, V as S, Ee as T, ve as U, _e as V, be as W, S as X, C as Y, de as Z, je as _, qe as a, u as at, H as b, Ve as c, l as ct, ze as d, o as dt, g as et, Le as f, Pe as g, Ne as h, Ke as i, p as it, F as j, I as k, Re as l, c as lt, Me as m, Y as n, te as nt, $ as o, d as ot, Fe as p, me as q, Ge as r, m as rt, He as s, f as st, Ue as t, h as tt, Be as u, s as ut, G as v, z as w, U as x, Oe as y, O as z };
|