@e-xi/xion 0.0.6
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/README.md +1 -0
- package/dist/bin/icon-generator.d.ts +22 -0
- package/dist/bin/index.d.ts +5 -0
- package/dist/bin/index.js +92 -0
- package/dist/bin/logo-generator.d.ts +22 -0
- package/dist/chunk-files/chunk-34OODP7M.js +147 -0
- package/dist/chunk-files/chunk-3KBZWBNP.js +51 -0
- package/dist/chunk-files/chunk-3R6EJDYR.js +10 -0
- package/dist/chunk-files/chunk-3RVKOFMP.js +68 -0
- package/dist/chunk-files/chunk-3S5OTD47.js +35 -0
- package/dist/chunk-files/chunk-3XB4IEWO.js +195 -0
- package/dist/chunk-files/chunk-3XOVD6UX.js +8 -0
- package/dist/chunk-files/chunk-4HEDNQUP.js +426 -0
- package/dist/chunk-files/chunk-4SSGMLEE.js +934 -0
- package/dist/chunk-files/chunk-5PKWVAQP.js +92 -0
- package/dist/chunk-files/chunk-6BOPFOZD.js +19 -0
- package/dist/chunk-files/chunk-6FDO72PN.js +25 -0
- package/dist/chunk-files/chunk-6X74EPRM.js +0 -0
- package/dist/chunk-files/chunk-B2FI5WI5.js +67 -0
- package/dist/chunk-files/chunk-B7DTBTWQ.js +74 -0
- package/dist/chunk-files/chunk-BFD2LHLK.js +60 -0
- package/dist/chunk-files/chunk-BJOPQNB2.js +319 -0
- package/dist/chunk-files/chunk-BMOLIJ3W.js +89 -0
- package/dist/chunk-files/chunk-BPTFUGTP.js +97 -0
- package/dist/chunk-files/chunk-CSUNGWAE.js +405 -0
- package/dist/chunk-files/chunk-D5ZV4VMI.js +627 -0
- package/dist/chunk-files/chunk-DD6WZ4NY.js +841 -0
- package/dist/chunk-files/chunk-DEODEAKM.js +19 -0
- package/dist/chunk-files/chunk-DRMV3M5V.js +1970 -0
- package/dist/chunk-files/chunk-EQTU45UO.js +21 -0
- package/dist/chunk-files/chunk-F7YTK2MY.js +154 -0
- package/dist/chunk-files/chunk-FMQTZ3QV.js +17 -0
- package/dist/chunk-files/chunk-FPN7JYR4.js +67 -0
- package/dist/chunk-files/chunk-FULHNQ4O.js +1243 -0
- package/dist/chunk-files/chunk-GN2FNR3Z.js +259 -0
- package/dist/chunk-files/chunk-GROGDGEL.js +177 -0
- package/dist/chunk-files/chunk-GUOSVDXA.js +34 -0
- package/dist/chunk-files/chunk-HT5V5A7S.js +6 -0
- package/dist/chunk-files/chunk-ID3YDA2K.js +19 -0
- package/dist/chunk-files/chunk-IH3R2NDR.js +230 -0
- package/dist/chunk-files/chunk-IMGYTSWY.js +261 -0
- package/dist/chunk-files/chunk-J34MOWJP.js +26 -0
- package/dist/chunk-files/chunk-KFK47PDH.js +77 -0
- package/dist/chunk-files/chunk-KFV4GXVE.js +11 -0
- package/dist/chunk-files/chunk-LFHJJQW3.js +723 -0
- package/dist/chunk-files/chunk-LQ67F6EY.js +32 -0
- package/dist/chunk-files/chunk-MJ6Q3TIX.js +703 -0
- package/dist/chunk-files/chunk-OUFO3LM4.js +135 -0
- package/dist/chunk-files/chunk-P4CX6I4J.js +14 -0
- package/dist/chunk-files/chunk-PL5KNBCY.js +78 -0
- package/dist/chunk-files/chunk-PVWRRUOK.js +11 -0
- package/dist/chunk-files/chunk-Q7LCZIQP.js +15 -0
- package/dist/chunk-files/chunk-Q7YMMN7J.js +220 -0
- package/dist/chunk-files/chunk-RAVPJRBA.js +118 -0
- package/dist/chunk-files/chunk-RN7AI33H.js +26 -0
- package/dist/chunk-files/chunk-RODB64YF.js +148 -0
- package/dist/chunk-files/chunk-SVTZ4T6S.js +10 -0
- package/dist/chunk-files/chunk-T3QCAOCO.js +20 -0
- package/dist/chunk-files/chunk-U4XEWVBH.js +19 -0
- package/dist/chunk-files/chunk-UCMR6V67.js +746 -0
- package/dist/chunk-files/chunk-UFYEZIUE.js +1269 -0
- package/dist/chunk-files/chunk-UIJUY7QZ.js +18 -0
- package/dist/chunk-files/chunk-VGDNICVG.js +67 -0
- package/dist/chunk-files/chunk-W2I3I7U7.js +35 -0
- package/dist/chunk-files/chunk-WGYOMA43.js +33 -0
- package/dist/chunk-files/chunk-WKVLVI6N.js +44 -0
- package/dist/chunk-files/chunk-WOJ2UKI7.js +11 -0
- package/dist/chunk-files/chunk-Y3OEXVQ2.js +59 -0
- package/dist/chunk-files/chunk-YLZRRUY7.js +6 -0
- package/dist/chunk-files/chunk-YTHS2ZV7.js +51 -0
- package/dist/chunk-files/chunk-YXAEUJKJ.js +331 -0
- package/dist/chunk-files/chunk-YZOJOLFL.js +121 -0
- package/dist/main/app/app-lifecycle-abstract.d.ts +190 -0
- package/dist/main/app/app-lifecycle.d.ts +7 -0
- package/dist/main/app/icons/icon.ico +0 -0
- package/dist/main/app/index.d.ts +8 -0
- package/dist/main/app/index.js +1226 -0
- package/dist/main/app/types/app.d.ts +74 -0
- package/dist/main/app/xo-app-abstract.d.ts +464 -0
- package/dist/main/app/xo-app.d.ts +23 -0
- package/dist/main/auth/index.d.ts +8 -0
- package/dist/main/auth/index.js +109 -0
- package/dist/main/auth/jwt-auth-manager.d.ts +302 -0
- package/dist/main/auth/jwt-auth-provider-abstract.d.ts +100 -0
- package/dist/main/auth/jwt-auth-refresh-rejected-error.d.ts +12 -0
- package/dist/main/auth/jwt-auth-session-changed-error.d.ts +12 -0
- package/dist/main/auth/types/jwt-auth-manager.d.ts +13 -0
- package/dist/main/banner/banner-abstract.d.ts +38 -0
- package/dist/main/banner/banner-manager.d.ts +20 -0
- package/dist/main/banner/index.d.ts +6 -0
- package/dist/main/banner/index.js +10 -0
- package/dist/main/banner/types/banner.d.ts +17 -0
- package/dist/main/config/app-config.d.ts +6 -0
- package/dist/main/config/index.d.ts +13 -0
- package/dist/main/config/index.js +33 -0
- package/dist/main/config/logger-config.d.ts +6 -0
- package/dist/main/config/remote-service-config.d.ts +6 -0
- package/dist/main/config/tray-config.d.ts +6 -0
- package/dist/main/config/types/app.d.ts +38 -0
- package/dist/main/config/types/logger.d.ts +82 -0
- package/dist/main/config/types/window.d.ts +35 -0
- package/dist/main/config/updater-config.d.ts +6 -0
- package/dist/main/config/window/main-window-config.d.ts +6 -0
- package/dist/main/config/window/setting-window-config.d.ts +6 -0
- package/dist/main/file-association/file-association-handlers-abstract.d.ts +23 -0
- package/dist/main/file-association/file-association-manager-abstract.d.ts +87 -0
- package/dist/main/file-association/file-association-manager.d.ts +13 -0
- package/dist/main/file-association/handlers/app-file-association-handlers.d.ts +12 -0
- package/dist/main/file-association/index.d.ts +8 -0
- package/dist/main/file-association/index.js +13 -0
- package/dist/main/file-association/types/file-association.d.ts +31 -0
- package/dist/main/ipc/handlers/app-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/auth-handlers.d.ts +12 -0
- package/dist/main/ipc/handlers/clipboard-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/contex-menu-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/dialog-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/file-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/log-handlers.d.ts +45 -0
- package/dist/main/ipc/handlers/remote-service-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/shell-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/theme-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/updater-handlers.d.ts +13 -0
- package/dist/main/ipc/handlers/window-handlers.d.ts +13 -0
- package/dist/main/ipc/index.d.ts +20 -0
- package/dist/main/ipc/index.js +60 -0
- package/dist/main/ipc/ipc-handlers-abstract.d.ts +23 -0
- package/dist/main/ipc/ipc-manager-abstract.d.ts +46 -0
- package/dist/main/ipc/ipc-manager.d.ts +13 -0
- package/dist/main/ipc/types/ipc-handler.d.ts +22 -0
- package/dist/main/ipc/utils/ipc-handler-util.d.ts +24 -0
- package/dist/main/logger/index.d.ts +4 -0
- package/dist/main/logger/index.js +13 -0
- package/dist/main/logger/xo-logger.d.ts +113 -0
- package/dist/main/menu/consts/menu-type.d.ts +1 -0
- package/dist/main/menu/index.d.ts +8 -0
- package/dist/main/menu/index.js +28 -0
- package/dist/main/menu/menu-items.d.ts +192 -0
- package/dist/main/menu/menu-manager-abstract.d.ts +273 -0
- package/dist/main/menu/menu-manager.d.ts +12 -0
- package/dist/main/menu/types/menu.d.ts +101 -0
- package/dist/main/mode/app-mode.d.ts +32 -0
- package/dist/main/mode/index.d.ts +5 -0
- package/dist/main/mode/index.js +9 -0
- package/dist/main/mode/types/mode.d.ts +25 -0
- package/dist/main/protocol/consts/protocol-keys.d.ts +10 -0
- package/dist/main/protocol/handlers/app-protocol-handlers.d.ts +12 -0
- package/dist/main/protocol/index.d.ts +9 -0
- package/dist/main/protocol/index.js +15 -0
- package/dist/main/protocol/protocol-handlers-abstract.d.ts +23 -0
- package/dist/main/protocol/protocol-manager-abstract.d.ts +85 -0
- package/dist/main/protocol/protocol-manager.d.ts +13 -0
- package/dist/main/protocol/types/protocol.d.ts +33 -0
- package/dist/main/remote-service/consts/remote-service-methods.d.ts +5 -0
- package/dist/main/remote-service/index.d.ts +7 -0
- package/dist/main/remote-service/index.js +17 -0
- package/dist/main/remote-service/remote-service-manager-abstract.d.ts +303 -0
- package/dist/main/remote-service/remote-service-manager.d.ts +7 -0
- package/dist/main/remote-service/types/remote-service.d.ts +9 -0
- package/dist/main/renderer-protocol/handlers/renderer-remote-service-protocol-handlers.d.ts +130 -0
- package/dist/main/renderer-protocol/handlers/renderer-root-protocol-handlers.d.ts +65 -0
- package/dist/main/renderer-protocol/index.d.ts +9 -0
- package/dist/main/renderer-protocol/index.js +18 -0
- package/dist/main/renderer-protocol/renderer-protocol-handlers-abstract.d.ts +23 -0
- package/dist/main/renderer-protocol/renderer-protocol-manager-abstract.d.ts +78 -0
- package/dist/main/renderer-protocol/renderer-protocol-manager.d.ts +13 -0
- package/dist/main/renderer-protocol/types/renderer-protocol.d.ts +34 -0
- package/dist/main/shortcut/handlers/app-shortcut-handlers.d.ts +11 -0
- package/dist/main/shortcut/handlers/window-shortcut-handlers.d.ts +11 -0
- package/dist/main/shortcut/index.d.ts +9 -0
- package/dist/main/shortcut/index.js +17 -0
- package/dist/main/shortcut/shortcut-handlers-abstract.d.ts +18 -0
- package/dist/main/shortcut/shortcut-manager-abstract.d.ts +121 -0
- package/dist/main/shortcut/shortcut-manager.d.ts +12 -0
- package/dist/main/shortcut/types/shortcut.d.ts +50 -0
- package/dist/main/store/app-store.d.ts +179 -0
- package/dist/main/store/index.d.ts +7 -0
- package/dist/main/store/index.js +13 -0
- package/dist/main/store/jwt-auth-store.d.ts +36 -0
- package/dist/main/store/types/app-store.d.ts +46 -0
- package/dist/main/store/types/jwt-auth-store.d.ts +14 -0
- package/dist/main/theme/consts/theme-sources.d.ts +10 -0
- package/dist/main/theme/index.d.ts +7 -0
- package/dist/main/theme/index.js +16 -0
- package/dist/main/theme/theme-manager-abstract.d.ts +93 -0
- package/dist/main/theme/theme-manager.d.ts +7 -0
- package/dist/main/theme/types/theme.d.ts +38 -0
- package/dist/main/tray/consts/tray-animation-name.d.ts +1 -0
- package/dist/main/tray/consts/tray-icon-name.d.ts +1 -0
- package/dist/main/tray/icons/blur.ico +0 -0
- package/dist/main/tray/icons/error.ico +0 -0
- package/dist/main/tray/icons/focus.ico +0 -0
- package/dist/main/tray/icons/none.ico +0 -0
- package/dist/main/tray/icons/offline.ico +0 -0
- package/dist/main/tray/icons/online.ico +0 -0
- package/dist/main/tray/icons/success.ico +0 -0
- package/dist/main/tray/index.d.ts +11 -0
- package/dist/main/tray/index.js +27 -0
- package/dist/main/tray/tray-animation.d.ts +48 -0
- package/dist/main/tray/tray-icon.d.ts +51 -0
- package/dist/main/tray/tray-lifecycle-abstract.d.ts +154 -0
- package/dist/main/tray/tray-lifecycle.d.ts +7 -0
- package/dist/main/tray/tray-manager.d.ts +173 -0
- package/dist/main/tray/types/tray.d.ts +81 -0
- package/dist/main/updater/dev-app-update.yml +5 -0
- package/dist/main/updater/index.d.ts +6 -0
- package/dist/main/updater/index.js +20 -0
- package/dist/main/updater/types/updater.d.ts +167 -0
- package/dist/main/updater/updater-manager-abstract.d.ts +237 -0
- package/dist/main/updater/updater-manager.d.ts +7 -0
- package/dist/main/utils/file-association-util.d.ts +43 -0
- package/dist/main/utils/index.d.ts +14 -0
- package/dist/main/utils/index.js +105 -0
- package/dist/main/utils/menu-util.d.ts +12 -0
- package/dist/main/utils/protocol-util.d.ts +49 -0
- package/dist/main/utils/runtime-config-util.d.ts +75 -0
- package/dist/main/utils/shortcut-util.d.ts +38 -0
- package/dist/main/utils/tray-util.d.ts +18 -0
- package/dist/main/utils/window-util.d.ts +55 -0
- package/dist/main/utils/xo-app-root-util.d.ts +30 -0
- package/dist/main/utils/xo-app-util.d.ts +24 -0
- package/dist/main/utils/xo-path-util.d.ts +59 -0
- package/dist/main/utils/xo-util.d.ts +17 -0
- package/dist/main/window/index.d.ts +10 -0
- package/dist/main/window/index.js +36 -0
- package/dist/main/window/main/main-window-lifecycle.d.ts +7 -0
- package/dist/main/window/main/main-window-type.d.ts +5 -0
- package/dist/main/window/setting/setting-window-lifecycle.d.ts +7 -0
- package/dist/main/window/setting/setting-window-type.d.ts +5 -0
- package/dist/main/window/types/window.d.ts +86 -0
- package/dist/main/window/window-lifecycle-abstract.d.ts +514 -0
- package/dist/main/window/window-manager.d.ts +422 -0
- package/dist/preload/bridge/bridge-abstract.d.ts +11 -0
- package/dist/preload/bridge/bridge.d.ts +35 -0
- package/dist/preload/bridge/index.d.ts +6 -0
- package/dist/preload/bridge/index.js +117 -0
- package/dist/preload/bridge/preload.cjs +1706 -0
- package/dist/preload/bridge/preload.internal.d.ts +1 -0
- package/dist/preload/bridge/types/bridge.d.ts +19 -0
- package/dist/preload/bridges/app/app-bridge.d.ts +142 -0
- package/dist/preload/bridges/app/types/app.d.ts +65 -0
- package/dist/preload/bridges/auth/auth-bridge.d.ts +36 -0
- package/dist/preload/bridges/auth/types/auth.d.ts +23 -0
- package/dist/preload/bridges/clipboard/clipboard-bridge.d.ts +37 -0
- package/dist/preload/bridges/clipboard/types/clipboard.d.ts +23 -0
- package/dist/preload/bridges/context-menu/context-menu-bridge.d.ts +27 -0
- package/dist/preload/bridges/context-menu/types/context-menu.d.ts +19 -0
- package/dist/preload/bridges/dialog/dialog-bridge.d.ts +30 -0
- package/dist/preload/bridges/dialog/types/dialog.d.ts +41 -0
- package/dist/preload/bridges/file/file-bridge.d.ts +34 -0
- package/dist/preload/bridges/file/types/file.d.ts +21 -0
- package/dist/preload/bridges/index.d.ts +29 -0
- package/dist/preload/bridges/index.js +40 -0
- package/dist/preload/bridges/ipc/ipc-bridge.d.ts +43 -0
- package/dist/preload/bridges/ipc/types/ipc.d.ts +23 -0
- package/dist/preload/bridges/log/log-bridge.d.ts +52 -0
- package/dist/preload/bridges/log/types/log.d.ts +20 -0
- package/dist/preload/bridges/remote-service/remote-service-bridge.d.ts +55 -0
- package/dist/preload/bridges/remote-service/types/remote-service.d.ts +29 -0
- package/dist/preload/bridges/shell/shell-bridge.d.ts +27 -0
- package/dist/preload/bridges/shell/types/shell.d.ts +19 -0
- package/dist/preload/bridges/theme/theme-bridge.d.ts +32 -0
- package/dist/preload/bridges/theme/types/theme.d.ts +21 -0
- package/dist/preload/bridges/updater/types/updater.d.ts +35 -0
- package/dist/preload/bridges/updater/updater-bridge.d.ts +66 -0
- package/dist/preload/bridges/window/internal/route-redirect-buffer.d.ts +36 -0
- package/dist/preload/bridges/window/types/window.d.ts +53 -0
- package/dist/preload/bridges/window/window-bridge.d.ts +118 -0
- package/dist/preload/utils/bridge-util.d.ts +43 -0
- package/dist/preload/utils/index.d.ts +4 -0
- package/dist/preload/utils/index.js +7 -0
- package/dist/renderer/app/bootstrap-renderer.d.ts +6 -0
- package/dist/renderer/app/index.d.ts +5 -0
- package/dist/renderer/app/index.js +164 -0
- package/dist/renderer/app/styles-element-plus.internal.d.ts +2 -0
- package/dist/renderer/app/styles-xion.internal.d.ts +2 -0
- package/dist/renderer/app/types/app.d.ts +51 -0
- package/dist/renderer/components/captcha/internal/captcha-controller.d.ts +280 -0
- package/dist/renderer/components/captcha/internal/captcha-css-property.d.ts +25 -0
- package/dist/renderer/components/captcha/internal/captcha-defaults.d.ts +33 -0
- package/dist/renderer/components/captcha/internal/captcha-errors.d.ts +21 -0
- package/dist/renderer/components/captcha/internal/captcha-helper.d.ts +72 -0
- package/dist/renderer/components/captcha/internal/captcha-injector.d.ts +16 -0
- package/dist/renderer/components/captcha/internal/captcha-runtime-types.d.ts +153 -0
- package/dist/renderer/components/captcha/internal/captcha-service.d.ts +22 -0
- package/dist/renderer/components/captcha/internal/captcha-slide-types.d.ts +62 -0
- package/dist/renderer/components/captcha/internal/captcha-ui-patch.d.ts +43 -0
- package/dist/renderer/components/captcha/internal/captcha-wasm-loader.d.ts +36 -0
- package/dist/renderer/components/captcha/style/index.less +132 -0
- package/dist/renderer/components/captcha/types/captcha.d.ts +132 -0
- package/dist/renderer/components/captcha/xo-captcha-host.vue +151 -0
- package/dist/renderer/components/captcha/xo-captcha.vue +83 -0
- package/dist/renderer/components/captcha.d.ts +40 -0
- package/dist/renderer/components/context-menu/types/context-menu.d.ts +55 -0
- package/dist/renderer/components/context-menu/xo-context-menu-items.vue +112 -0
- package/dist/renderer/components/context-menu/xo-context-menu.vue +356 -0
- package/dist/renderer/components/context-menu.d.ts +32 -0
- package/dist/renderer/components/divider/types/divider.d.ts +31 -0
- package/dist/renderer/components/divider/xo-divider.vue +176 -0
- package/dist/renderer/components/form/types/form-flex-row.d.ts +21 -0
- package/dist/renderer/components/form/types/form-flex.d.ts +49 -0
- package/dist/renderer/components/form/xo-form-flex-row.vue +122 -0
- package/dist/renderer/components/form/xo-form-flex.vue +115 -0
- package/dist/renderer/components/index.d.ts +70 -0
- package/dist/renderer/components/index.js +1282 -0
- package/dist/renderer/components/layouts/types/app-layout.d.ts +29 -0
- package/dist/renderer/components/layouts/types/mini-layout.d.ts +23 -0
- package/dist/renderer/components/layouts/types/simple-layout.d.ts +17 -0
- package/dist/renderer/components/layouts/xo-app-layout.vue +350 -0
- package/dist/renderer/components/layouts/xo-mini-layout.vue +207 -0
- package/dist/renderer/components/layouts/xo-simple-layout.vue +43 -0
- package/dist/renderer/components/pages/types/app-page.d.ts +25 -0
- package/dist/renderer/components/pages/types/bootstrap-page.d.ts +35 -0
- package/dist/renderer/components/pages/types/dynamic-page.d.ts +20 -0
- package/dist/renderer/components/pages/types/settings-page.d.ts +23 -0
- package/dist/renderer/components/pages/xo-app-page.vue +230 -0
- package/dist/renderer/components/pages/xo-bootstrap-page.vue +93 -0
- package/dist/renderer/components/pages/xo-dynamic-page.vue +28 -0
- package/dist/renderer/components/pages/xo-settings-page.vue +143 -0
- package/dist/renderer/components/radio-group/types/radio-group.d.ts +30 -0
- package/dist/renderer/components/radio-group/xo-radio-group.vue +38 -0
- package/dist/renderer/components/service-status-bar/types/service-status-bar.d.ts +65 -0
- package/dist/renderer/components/service-status-bar/xo-service-status-bar.vue +193 -0
- package/dist/renderer/components/settings-components/types/setting-app-opacity.d.ts +19 -0
- package/dist/renderer/components/settings-components/types/setting-log-level.d.ts +23 -0
- package/dist/renderer/components/settings-components/types/setting-shortcut-keys-record-for-form-flex-rows.d.ts +47 -0
- package/dist/renderer/components/settings-components/types/setting-shortcut-keys-record.d.ts +23 -0
- package/dist/renderer/components/settings-components/types/setting-window-material.d.ts +23 -0
- package/dist/renderer/components/settings-components/xo-setting-app-opacity.vue +105 -0
- package/dist/renderer/components/settings-components/xo-setting-log-level.vue +84 -0
- package/dist/renderer/components/settings-components/xo-setting-shortcut-keys-record-for-form-flex-rows.vue +37 -0
- package/dist/renderer/components/settings-components/xo-setting-shortcut-keys-record.vue +74 -0
- package/dist/renderer/components/settings-components/xo-setting-window-material.vue +83 -0
- package/dist/renderer/components/settings-pages/types/setting-page-folder.d.ts +41 -0
- package/dist/renderer/components/settings-pages/types/setting-page-general.d.ts +23 -0
- package/dist/renderer/components/settings-pages/types/setting-page-remote-service.d.ts +19 -0
- package/dist/renderer/components/settings-pages/types/setting-page-updater.d.ts +27 -0
- package/dist/renderer/components/settings-pages/xo-setting-page-folder.vue +137 -0
- package/dist/renderer/components/settings-pages/xo-setting-page-general.vue +255 -0
- package/dist/renderer/components/settings-pages/xo-setting-page-remote-service.vue +183 -0
- package/dist/renderer/components/settings-pages/xo-setting-page-updater.vue +350 -0
- package/dist/renderer/components/shortcut-keys-record/types/shortcut-keys-record.d.ts +25 -0
- package/dist/renderer/components/shortcut-keys-record/xo-shortcut-keys-record.vue +161 -0
- package/dist/renderer/components/side-bar/types/sidebar-logo.d.ts +39 -0
- package/dist/renderer/components/side-bar/xo-sidebar-logo.vue +133 -0
- package/dist/renderer/components/spacing-line/types/spacing-line.d.ts +17 -0
- package/dist/renderer/components/spacing-line/xo-spacing-line.vue +53 -0
- package/dist/renderer/components/theme-switch/types/theme-switch-mini.d.ts +21 -0
- package/dist/renderer/components/theme-switch/types/theme-switch.d.ts +45 -0
- package/dist/renderer/components/theme-switch/xo-theme-switch-mini.vue +93 -0
- package/dist/renderer/components/theme-switch/xo-theme-switch.vue +200 -0
- package/dist/renderer/components/title-bar/types/title-bar.d.ts +58 -0
- package/dist/renderer/components/title-bar/xo-title-bar.vue +364 -0
- package/dist/renderer/components/types/sidebar-menu.d.ts +37 -0
- package/dist/renderer/components/types/vue.d.ts +9 -0
- package/dist/renderer/components/updater/types/updater.d.ts +97 -0
- package/dist/renderer/components/updater/xo-updater.vue +1190 -0
- package/dist/renderer/components/window-control/types/window-control.d.ts +17 -0
- package/dist/renderer/components/window-control/xo-window-control.vue +193 -0
- package/dist/renderer/composables/index.d.ts +7 -0
- package/dist/renderer/composables/index.js +570 -0
- package/dist/renderer/composables/use-xo-boolean.d.ts +14 -0
- package/dist/renderer/composables/use-xo-data-loader.d.ts +73 -0
- package/dist/renderer/composables/use-xo-form-control.d.ts +84 -0
- package/dist/renderer/composables/use-xo-updater-action.d.ts +25 -0
- package/dist/renderer/global/index.d.ts +4 -0
- package/dist/renderer/global/index.js +0 -0
- package/dist/renderer/global/types/window.d.ts +21 -0
- package/dist/renderer/icons/demo.css +539 -0
- package/dist/renderer/icons/iconfont.css +490 -0
- package/dist/renderer/services/index.d.ts +6 -0
- package/dist/renderer/services/index.js +444 -0
- package/dist/renderer/services/orval-axios-mutator.d.ts +9 -0
- package/dist/renderer/services/types/xo-api.d.ts +92 -0
- package/dist/renderer/services/xo-api-requester.d.ts +129 -0
- package/dist/renderer/store/app/app-store.d.ts +68 -0
- package/dist/renderer/store/auth/auth-store.d.ts +43 -0
- package/dist/renderer/store/index.d.ts +9 -0
- package/dist/renderer/store/index.js +595 -0
- package/dist/renderer/store/remote-service/remote-service-store.d.ts +52 -0
- package/dist/renderer/store/theme/theme-store.d.ts +52 -0
- package/dist/renderer/store/updater/updater-store.d.ts +88 -0
- package/dist/renderer/store/window/window-store.d.ts +58 -0
- package/dist/renderer/styles/css/element-plus.less +280 -0
- package/dist/renderer/styles/css/iconfont-patch.less +6 -0
- package/dist/renderer/styles/css/reset.less +83 -0
- package/dist/renderer/styles/css/scrollbar.less +56 -0
- package/dist/renderer/styles/index.less +35 -0
- package/dist/renderer/styles/mixin.less +144 -0
- package/dist/renderer/styles/var/element-plus/dark.less +32 -0
- package/dist/renderer/styles/var/element-plus/root.less +88 -0
- package/dist/renderer/styles/var/global/dark.less +10 -0
- package/dist/renderer/styles/var/global/root.less +46 -0
- package/dist/renderer/styles/var/layout/dark.less +7 -0
- package/dist/renderer/styles/var/layout/root.less +9 -0
- package/dist/renderer/styles/var/scrollbar/dark.less +13 -0
- package/dist/renderer/styles/var/scrollbar/root.less +35 -0
- package/dist/renderer/utils/auth-route-util.d.ts +117 -0
- package/dist/renderer/utils/context-util.d.ts +13 -0
- package/dist/renderer/utils/error-util.d.ts +12 -0
- package/dist/renderer/utils/index.d.ts +14 -0
- package/dist/renderer/utils/index.js +1522 -0
- package/dist/renderer/utils/keyboard-util.d.ts +86 -0
- package/dist/renderer/utils/message-util.d.ts +161 -0
- package/dist/renderer/utils/renderer-log-util.d.ts +44 -0
- package/dist/renderer/utils/renderer-util.d.ts +37 -0
- package/dist/renderer/utils/router-util.d.ts +186 -0
- package/dist/renderer/utils/shortcut-util.d.ts +20 -0
- package/dist/renderer/utils/storage-util.d.ts +85 -0
- package/dist/renderer/utils/types/vue-router.d.ts +17 -0
- package/dist/shared/app/consts/app-launch-mode.d.ts +9 -0
- package/dist/shared/app/consts/update-mode.d.ts +8 -0
- package/dist/shared/app/consts/window-close-behavior.d.ts +8 -0
- package/dist/shared/app/consts/window-material.d.ts +8 -0
- package/dist/shared/app/consts/xion-name.d.ts +5 -0
- package/dist/shared/app/electron-app-config.d.ts +5 -0
- package/dist/shared/app/index.d.ts +16 -0
- package/dist/shared/app/index.js +30 -0
- package/dist/shared/app/types/app-info.d.ts +32 -0
- package/dist/shared/app/types/app-launch-mode.d.ts +13 -0
- package/dist/shared/app/types/app-paths.d.ts +27 -0
- package/dist/shared/app/types/general-settings.d.ts +27 -0
- package/dist/shared/app/types/on-window-close.d.ts +13 -0
- package/dist/shared/app/types/update-mode.d.ts +13 -0
- package/dist/shared/app/types/window-material.d.ts +2 -0
- package/dist/shared/auth/const/auth-status.d.ts +2 -0
- package/dist/shared/auth/index.d.ts +5 -0
- package/dist/shared/auth/index.js +5 -0
- package/dist/shared/auth/types/auth.d.ts +78 -0
- package/dist/shared/color/consts/color.d.ts +5 -0
- package/dist/shared/color/index.d.ts +5 -0
- package/dist/shared/color/index.js +6 -0
- package/dist/shared/color/types/color.d.ts +26 -0
- package/dist/shared/electron-builder/index.d.ts +4 -0
- package/dist/shared/electron-builder/index.js +0 -0
- package/dist/shared/electron-builder/types/electron-builder-options.d.ts +34 -0
- package/dist/shared/errors/index.d.ts +4 -0
- package/dist/shared/errors/index.js +10 -0
- package/dist/shared/errors/ipc-invoke-error.d.ts +32 -0
- package/dist/shared/ipc/channels/app-channels.d.ts +56 -0
- package/dist/shared/ipc/channels/auth-channels.d.ts +14 -0
- package/dist/shared/ipc/channels/clipboard-channels.d.ts +14 -0
- package/dist/shared/ipc/channels/context-menu-channels.d.ts +10 -0
- package/dist/shared/ipc/channels/dialog-channels.d.ts +12 -0
- package/dist/shared/ipc/channels/file-channels.d.ts +12 -0
- package/dist/shared/ipc/channels/log-channels.d.ts +14 -0
- package/dist/shared/ipc/channels/remote-service-channels.d.ts +20 -0
- package/dist/shared/ipc/channels/shell-channels.d.ts +10 -0
- package/dist/shared/ipc/channels/theme-channels.d.ts +12 -0
- package/dist/shared/ipc/channels/updater-channels.d.ts +26 -0
- package/dist/shared/ipc/channels/window-channels.d.ts +44 -0
- package/dist/shared/ipc/consts/ipc-channel.d.ts +1 -0
- package/dist/shared/ipc/index.d.ts +19 -0
- package/dist/shared/ipc/index.js +46 -0
- package/dist/shared/ipc/ipc-result.d.ts +20 -0
- package/dist/shared/ipc/types/ipc-logger.d.ts +27 -0
- package/dist/shared/ipc/types/ipc.d.ts +61 -0
- package/dist/shared/logger/consts/log-levels.d.ts +14 -0
- package/dist/shared/logger/index.d.ts +4 -0
- package/dist/shared/logger/index.js +10 -0
- package/dist/shared/menu/consts/menu-command.d.ts +1 -0
- package/dist/shared/menu/index.d.ts +6 -0
- package/dist/shared/menu/index.js +10 -0
- package/dist/shared/menu/menu-command.d.ts +24 -0
- package/dist/shared/menu/types/menu.d.ts +72 -0
- package/dist/shared/mode/consts/command.d.ts +10 -0
- package/dist/shared/mode/consts/mode.d.ts +22 -0
- package/dist/shared/mode/index.d.ts +5 -0
- package/dist/shared/mode/index.js +18 -0
- package/dist/shared/remote-service/const/remote-service.d.ts +8 -0
- package/dist/shared/remote-service/index.d.ts +5 -0
- package/dist/shared/remote-service/index.js +38 -0
- package/dist/shared/remote-service/types/remote-service.d.ts +146 -0
- package/dist/shared/renderer/index.d.ts +7 -0
- package/dist/shared/renderer/index.js +0 -0
- package/dist/shared/renderer/types/element-plus.d.ts +20 -0
- package/dist/shared/renderer/types/input.d.ts +11 -0
- package/dist/shared/renderer/types/options.d.ts +22 -0
- package/dist/shared/renderer/types/switch.d.ts +11 -0
- package/dist/shared/renderer-protocol/consts/renderer-protocol-keys.d.ts +10 -0
- package/dist/shared/renderer-protocol/index.d.ts +5 -0
- package/dist/shared/renderer-protocol/index.js +6 -0
- package/dist/shared/renderer-protocol/types/renderer-protocol.d.ts +7 -0
- package/dist/shared/runtime/index.d.ts +4 -0
- package/dist/shared/runtime/index.js +0 -0
- package/dist/shared/runtime/types/runtime.d.ts +20 -0
- package/dist/shared/shortcut/consts/shortcut-handler-ids.d.ts +9 -0
- package/dist/shared/shortcut/consts/shortcut-id.d.ts +1 -0
- package/dist/shared/shortcut/index.d.ts +6 -0
- package/dist/shared/shortcut/index.js +10 -0
- package/dist/shared/shortcut/types/shortcut.d.ts +13 -0
- package/dist/shared/utils/bytes-util.d.ts +16 -0
- package/dist/shared/utils/index.d.ts +15 -0
- package/dist/shared/utils/index.js +42 -0
- package/dist/shared/utils/ipc-util.d.ts +12 -0
- package/dist/shared/utils/log-util.d.ts +33 -0
- package/dist/shared/utils/menu-util.d.ts +12 -0
- package/dist/shared/utils/number-util.d.ts +12 -0
- package/dist/shared/utils/object-util.d.ts +88 -0
- package/dist/shared/utils/regexp-util.d.ts +22 -0
- package/dist/shared/utils/shortcut-util.d.ts +12 -0
- package/dist/shared/utils/string-util.d.ts +14 -0
- package/dist/shared/utils/time-util.d.ts +32 -0
- package/dist/shared/utils/validator-util.d.ts +12 -0
- package/dist/shared/utils/window-shared-util.d.ts +26 -0
- package/dist/shared/window/consts/window-record-id.d.ts +2 -0
- package/dist/shared/window/consts/window-type-name.d.ts +1 -0
- package/dist/shared/window/identity/main-window-identity.d.ts +5 -0
- package/dist/shared/window/identity/setting-window-identity.d.ts +5 -0
- package/dist/shared/window/index.d.ts +8 -0
- package/dist/shared/window/index.js +23 -0
- package/dist/shared/window/types/window.d.ts +84 -0
- package/dist/types/index.d.ts +102 -0
- package/dist/types/index.js +0 -0
- package/dist/vite/build/build-chunk.d.ts +53 -0
- package/dist/vite/build/build-csp-update.d.ts +80 -0
- package/dist/vite/build/build-obfuscation.d.ts +33 -0
- package/dist/vite/build/component-map.d.ts +38 -0
- package/dist/vite/build/component-resolver.d.ts +6 -0
- package/dist/vite/build/index.d.ts +9 -0
- package/dist/vite/build/index.js +18 -0
- package/dist/vite/build/types/build.d.ts +13 -0
- package/dist/vite/config/electron-app-config.d.ts +6 -0
- package/dist/vite/config/electron-builder-config.d.ts +8 -0
- package/dist/vite/config/electron-vite-config.d.ts +9 -0
- package/dist/vite/config/index.d.ts +11 -0
- package/dist/vite/config/index.js +2259 -0
- package/dist/vite/config/types/electron-app-options.d.ts +22 -0
- package/dist/vite/config/types/electron-builder-options.d.ts +16 -0
- package/dist/vite/config/types/electron-vite-options.d.ts +43 -0
- package/dist/vite/config/types/vite-obfuscation.d.ts +36 -0
- package/dist/vite/config/vite-obfuscation-config.d.ts +6 -0
- package/dist/vite/mode/index.d.ts +4 -0
- package/dist/vite/mode/index.js +8 -0
- package/dist/vite/mode/vite-mode.d.ts +37 -0
- package/dist/vite/orval/index.d.ts +4 -0
- package/dist/vite/orval/index.js +75 -0
- package/dist/vite/orval/orval-global-types.d.ts +23 -0
- package/dist/vite/utils/file-write-vite-util.d.ts +30 -0
- package/dist/vite/utils/index.d.ts +5 -0
- package/dist/vite/utils/index.js +10 -0
- package/dist/vite/utils/runtime-config-vite-util.d.ts +39 -0
- package/package.json +287 -0
|
@@ -0,0 +1,841 @@
|
|
|
1
|
+
import {
|
|
2
|
+
JwtAuthSessionChangedError,
|
|
3
|
+
RemoteServiceAllowedRequestMethods
|
|
4
|
+
} from "./chunk-J34MOWJP.js";
|
|
5
|
+
import {
|
|
6
|
+
RemoteServiceChannels
|
|
7
|
+
} from "./chunk-RN7AI33H.js";
|
|
8
|
+
import {
|
|
9
|
+
AppMode
|
|
10
|
+
} from "./chunk-GN2FNR3Z.js";
|
|
11
|
+
|
|
12
|
+
// src/main/remote-service/remote-service-manager-abstract.ts
|
|
13
|
+
import { BrowserWindow, session as electronSession } from "electron";
|
|
14
|
+
var safeHeaderNames = /* @__PURE__ */ new Set([
|
|
15
|
+
"authorization",
|
|
16
|
+
"x-refresh-token",
|
|
17
|
+
"x-device-id",
|
|
18
|
+
"cookie",
|
|
19
|
+
"host",
|
|
20
|
+
"content-length",
|
|
21
|
+
"connection"
|
|
22
|
+
]);
|
|
23
|
+
var RemoteServiceManagerAbstract = class {
|
|
24
|
+
/** Xion 应用 */
|
|
25
|
+
xoApp;
|
|
26
|
+
/** 是否已初始化 */
|
|
27
|
+
initialized = false;
|
|
28
|
+
/** 远程服务状态 */
|
|
29
|
+
state = {
|
|
30
|
+
status: "idle",
|
|
31
|
+
reconnectCount: 0
|
|
32
|
+
};
|
|
33
|
+
/** 心跳定时器 */
|
|
34
|
+
heartbeatTimer;
|
|
35
|
+
/** 重试定时器 */
|
|
36
|
+
retryTimer;
|
|
37
|
+
/** 快速重试耗尽后的低频探测定时器 */
|
|
38
|
+
lowFrequencyProbeTimer;
|
|
39
|
+
/** 当前探测请求的取消控制器 */
|
|
40
|
+
abortController;
|
|
41
|
+
/** 会话序号,用于忽略旧会话的异步结果 */
|
|
42
|
+
sessionId = 0;
|
|
43
|
+
/** 当前进行中探测所属的会话序号 */
|
|
44
|
+
probeSessionId = 0;
|
|
45
|
+
/** 本次运行期间连续失败次数 */
|
|
46
|
+
retryCount = 0;
|
|
47
|
+
/** 是否已手动停止连接 */
|
|
48
|
+
manualStopped = false;
|
|
49
|
+
/** 是否正在探测 */
|
|
50
|
+
probing = false;
|
|
51
|
+
/** 当前探测任务,用于合并并发探测请求 */
|
|
52
|
+
probePromise;
|
|
53
|
+
/** 主进程远程服务状态监听器 */
|
|
54
|
+
stateListeners = /* @__PURE__ */ new Set();
|
|
55
|
+
/**
|
|
56
|
+
* 构造函数
|
|
57
|
+
* @param {XoAppAbstract} xoApp Xion 应用
|
|
58
|
+
*/
|
|
59
|
+
constructor(xoApp) {
|
|
60
|
+
this.xoApp = xoApp;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 获取 Electron 默认会话
|
|
64
|
+
* @returns {Electron.Session}
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
electronSession() {
|
|
68
|
+
return electronSession.defaultSession;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 获取远程服务配置
|
|
72
|
+
* @returns {XoRemoteService.Config}
|
|
73
|
+
* @protected
|
|
74
|
+
*/
|
|
75
|
+
config() {
|
|
76
|
+
return this.xoApp.getRemoteServiceConfig() ?? {};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 获取远程服务用户设置
|
|
80
|
+
* @returns {XoRemoteService.UserSettings}
|
|
81
|
+
* @private
|
|
82
|
+
*/
|
|
83
|
+
getUserSettings() {
|
|
84
|
+
return { ...this.xoApp.getAppStore().getRemoteServiceSettings() };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 获取实际生效的远程服务设置
|
|
88
|
+
* <p>用户设置优先于配置</p>
|
|
89
|
+
* @returns {XoRemoteService.EffectiveSettings}
|
|
90
|
+
*/
|
|
91
|
+
getEffectiveSettings() {
|
|
92
|
+
const config = this.config();
|
|
93
|
+
const user = this.getUserSettings();
|
|
94
|
+
return {
|
|
95
|
+
enabled: user.enabled ?? config.enabled ?? false,
|
|
96
|
+
serviceUrl: (user.serviceUrl ?? config.serviceUrl ?? "").trim(),
|
|
97
|
+
connectionTimeout: user.connectionTimeout ?? config.connectionTimeout ?? 1e4,
|
|
98
|
+
retryCount: user.retryCount ?? config.retryCount ?? 3,
|
|
99
|
+
retryDelay: user.retryDelay ?? config.retryDelay ?? 3e3,
|
|
100
|
+
lowFrequencyProbeInterval: user.lowFrequencyProbeInterval ?? config.lowFrequencyProbeInterval ?? 3e4,
|
|
101
|
+
heartbeatInterval: user.heartbeatInterval ?? config.heartbeatInterval ?? 5e3,
|
|
102
|
+
heartbeatPath: (user.heartbeatPath ?? config.heartbeatPath)?.trim() || "/health",
|
|
103
|
+
requestCredentials: config.requestCredentials ?? "include",
|
|
104
|
+
requestRedirect: config.requestRedirect ?? "error"
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 设置远程服务用户设置
|
|
109
|
+
* @param {XoRemoteService.UserSettings} settings 远程服务用户设置
|
|
110
|
+
*/
|
|
111
|
+
setSettings(settings) {
|
|
112
|
+
this.validateUserSettings(settings);
|
|
113
|
+
this.xoApp.getAppStore().setRemoteServiceSettings(settings);
|
|
114
|
+
this.reconnect();
|
|
115
|
+
this.syncSettingsToAllWindows();
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 重置远程服务用户设置
|
|
119
|
+
*/
|
|
120
|
+
resetSettings() {
|
|
121
|
+
this.xoApp.getAppStore().resetRemoteServiceSettings();
|
|
122
|
+
this.reconnect();
|
|
123
|
+
this.syncSettingsToAllWindows();
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* 请求远程服务 API
|
|
127
|
+
* <p>当前接口面向 JSON 或文本请求;文件和流式数据使用渲染进程协议</p>
|
|
128
|
+
* <p>仅在远程服务连接成功后发起请求</p>
|
|
129
|
+
* @template T 响应数据类型
|
|
130
|
+
* @param {XoRemoteService.Request} request 请求参数
|
|
131
|
+
* @param {Session} targetSession 发起请求的渲染进程 Session,主进程调用时默认使用 defaultSession
|
|
132
|
+
* @param {RemoteServiceRequestOptions} options 主进程请求选项
|
|
133
|
+
* @returns {Promise<XoRemoteService.Response<T>>}
|
|
134
|
+
*/
|
|
135
|
+
async request(request, targetSession, options = {}) {
|
|
136
|
+
const settings = this.getEffectiveSettings();
|
|
137
|
+
if (!settings.enabled || !settings.serviceUrl) {
|
|
138
|
+
throw new Error("\u8FDC\u7A0B\u670D\u52A1\u672A\u542F\u7528\u6216\u672A\u914D\u7F6E\u670D\u52A1\u5730\u5740");
|
|
139
|
+
}
|
|
140
|
+
const authManager = this.xoApp.getAuthManager();
|
|
141
|
+
const authRevision = options.authentication === "none" ? void 0 : authManager.getAuthRevision();
|
|
142
|
+
targetSession ??= this.electronSession();
|
|
143
|
+
await this.ensureConnected();
|
|
144
|
+
this.requireAuthenticationRevision(authRevision);
|
|
145
|
+
const method = request.method.toUpperCase();
|
|
146
|
+
if (!RemoteServiceAllowedRequestMethods.has(method)) {
|
|
147
|
+
throw new Error(`\u8FDC\u7A0B\u670D\u52A1\u8BF7\u6C42\u65B9\u6CD5\u4E0D\u53D7\u652F\u6301: ${request.method}`);
|
|
148
|
+
}
|
|
149
|
+
const targetUrl = this.resolveRequestUrl(settings.serviceUrl, request);
|
|
150
|
+
let authorization = options.authentication === "none" ? void 0 : await authManager.getAuthorizationContext();
|
|
151
|
+
this.requireAuthenticationRevision(authRevision);
|
|
152
|
+
const authenticationHeaders = {
|
|
153
|
+
...options.authenticationHeaders,
|
|
154
|
+
...authManager.getDeviceIdHeaders()
|
|
155
|
+
};
|
|
156
|
+
let response = await this.executeRequest(
|
|
157
|
+
request,
|
|
158
|
+
targetSession,
|
|
159
|
+
settings,
|
|
160
|
+
method,
|
|
161
|
+
targetUrl,
|
|
162
|
+
authorization,
|
|
163
|
+
authenticationHeaders
|
|
164
|
+
);
|
|
165
|
+
this.requireAuthenticationRevision(authRevision);
|
|
166
|
+
if (response.status === 401 && authorization && options.retryUnauthorized !== false) {
|
|
167
|
+
authorization = await authManager.refreshAfterUnauthorized(authorization);
|
|
168
|
+
this.requireAuthenticationRevision(authRevision);
|
|
169
|
+
if (authorization) {
|
|
170
|
+
response = await this.executeRequest(
|
|
171
|
+
request,
|
|
172
|
+
targetSession,
|
|
173
|
+
settings,
|
|
174
|
+
method,
|
|
175
|
+
targetUrl,
|
|
176
|
+
authorization,
|
|
177
|
+
authenticationHeaders
|
|
178
|
+
);
|
|
179
|
+
this.requireAuthenticationRevision(authRevision);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return response;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* 校验请求所属认证会话未发生变化
|
|
186
|
+
* @param {number} expectedRevision 请求开始时的认证操作版本,未认证请求不传入
|
|
187
|
+
* @returns {void}
|
|
188
|
+
* @private
|
|
189
|
+
*/
|
|
190
|
+
requireAuthenticationRevision(expectedRevision) {
|
|
191
|
+
if (expectedRevision !== void 0 && this.xoApp.getAuthManager().getAuthRevision() !== expectedRevision) {
|
|
192
|
+
throw new JwtAuthSessionChangedError();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* 执行一次远程服务请求
|
|
197
|
+
* @template T 响应数据类型
|
|
198
|
+
* @param {XoRemoteService.Request} request 请求参数
|
|
199
|
+
* @param {Session} targetSession 发起请求的 Session
|
|
200
|
+
* @param {XoRemoteService.EffectiveSettings} settings 生效设置
|
|
201
|
+
* @param {XoRemoteService.Method} method 请求方法
|
|
202
|
+
* @param {URL} targetUrl 请求地址
|
|
203
|
+
* @param {JwtAuthorizationContext} authorization 访问令牌请求头上下文
|
|
204
|
+
* @param {Readonly<Record<string, string>>} authenticationHeaders 主进程内部认证请求头
|
|
205
|
+
* @returns {Promise<XoRemoteService.Response<T>>}
|
|
206
|
+
* @private
|
|
207
|
+
*/
|
|
208
|
+
async executeRequest(request, targetSession, settings, method, targetUrl, authorization, authenticationHeaders) {
|
|
209
|
+
const controller = new AbortController();
|
|
210
|
+
const body = this.buildRequestBody(request.body);
|
|
211
|
+
const timeout = setTimeout(() => controller.abort(), settings.connectionTimeout);
|
|
212
|
+
const headers = this.buildRequestHeaders(request, authorization, authenticationHeaders);
|
|
213
|
+
this.forceUserAgent(headers, targetSession);
|
|
214
|
+
try {
|
|
215
|
+
const upstream = await targetSession.fetch(targetUrl.toString(), {
|
|
216
|
+
method,
|
|
217
|
+
headers,
|
|
218
|
+
body: method === "GET" || method === "HEAD" ? void 0 : body,
|
|
219
|
+
credentials: settings.requestCredentials,
|
|
220
|
+
redirect: settings.requestRedirect,
|
|
221
|
+
signal: controller.signal
|
|
222
|
+
});
|
|
223
|
+
const responseHeaders = this.buildResponseHeaders(upstream.headers);
|
|
224
|
+
const contentType = upstream.headers.get("content-type")?.toLowerCase() ?? "";
|
|
225
|
+
const responseText = await upstream.text();
|
|
226
|
+
let data = responseText || void 0;
|
|
227
|
+
if (responseText && contentType.includes("application/json")) {
|
|
228
|
+
try {
|
|
229
|
+
data = JSON.parse(responseText);
|
|
230
|
+
} catch {
|
|
231
|
+
data = responseText;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
status: upstream.status,
|
|
236
|
+
statusText: upstream.statusText,
|
|
237
|
+
headers: responseHeaders,
|
|
238
|
+
data
|
|
239
|
+
};
|
|
240
|
+
} catch (error) {
|
|
241
|
+
throw this.toRequestError(error);
|
|
242
|
+
} finally {
|
|
243
|
+
clearTimeout(timeout);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* 构建远程服务请求地址
|
|
248
|
+
* @param {string} serviceUrl 服务基础地址
|
|
249
|
+
* @param {XoRemoteService.Request} request 请求参数
|
|
250
|
+
* @returns {URL}
|
|
251
|
+
* @private
|
|
252
|
+
*/
|
|
253
|
+
resolveRequestUrl(serviceUrl, request) {
|
|
254
|
+
const path = request.path.trim();
|
|
255
|
+
if (!path.startsWith("/") || path.startsWith("//")) {
|
|
256
|
+
throw new Error("\u8FDC\u7A0B\u670D\u52A1\u8BF7\u6C42\u8DEF\u5F84\u5FC5\u987B\u662F\u4EE5 / \u5F00\u5934\u7684\u76F8\u5BF9\u8DEF\u5F84");
|
|
257
|
+
}
|
|
258
|
+
const baseUrl = new URL(serviceUrl);
|
|
259
|
+
if (baseUrl.protocol !== "http:" && baseUrl.protocol !== "https:") {
|
|
260
|
+
throw new Error("\u8FDC\u7A0B\u670D\u52A1\u5730\u5740\u53EA\u652F\u6301 HTTP \u6216 HTTPS");
|
|
261
|
+
}
|
|
262
|
+
baseUrl.hash = "";
|
|
263
|
+
baseUrl.search = "";
|
|
264
|
+
baseUrl.pathname = `${baseUrl.pathname.replace(/\/+$/, "")}/`;
|
|
265
|
+
const targetUrl = new URL(path.replace(/^\/+/, ""), baseUrl);
|
|
266
|
+
if (targetUrl.origin !== baseUrl.origin || !targetUrl.pathname.startsWith(baseUrl.pathname)) {
|
|
267
|
+
throw new Error("\u8FDC\u7A0B\u670D\u52A1\u8BF7\u6C42\u8DEF\u5F84\u8D85\u51FA\u670D\u52A1\u5730\u5740\u8303\u56F4");
|
|
268
|
+
}
|
|
269
|
+
for (const [key, value] of Object.entries(request.query ?? {})) {
|
|
270
|
+
const values = Array.isArray(value) ? value : [value];
|
|
271
|
+
for (const item of values) {
|
|
272
|
+
targetUrl.searchParams.append(key, String(item));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return targetUrl;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* 构建请求头
|
|
279
|
+
* @param {XoRemoteService.Request} request 渲染进程请求
|
|
280
|
+
* @param {JwtAuthorizationContext} authorization 主进程管理的访问令牌请求头上下文
|
|
281
|
+
* @param {Readonly<Record<string, string>>} authenticationHeaders 主进程内部认证请求头
|
|
282
|
+
* @returns {Headers}
|
|
283
|
+
* @private
|
|
284
|
+
*/
|
|
285
|
+
buildRequestHeaders(request, authorization, authenticationHeaders) {
|
|
286
|
+
const refuseHeaderNames = /* @__PURE__ */ new Set([
|
|
287
|
+
// 主进程内部管理的请求头
|
|
288
|
+
...safeHeaderNames,
|
|
289
|
+
// 按远程服务认证策略管理的请求头
|
|
290
|
+
...this.xoApp.getAuthManager().getAuthenticationHeaderNames()
|
|
291
|
+
]);
|
|
292
|
+
const headers = new Headers();
|
|
293
|
+
for (const [name, value] of Object.entries(request.headers ?? {})) {
|
|
294
|
+
if (refuseHeaderNames.has(name.toLowerCase())) {
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
headers.set(name, value);
|
|
298
|
+
}
|
|
299
|
+
if (request.body !== void 0 && !headers.has("content-type")) {
|
|
300
|
+
headers.set("Content-Type", "application/json");
|
|
301
|
+
}
|
|
302
|
+
for (const [name, value] of Object.entries(authenticationHeaders ?? {})) {
|
|
303
|
+
headers.set(name, value);
|
|
304
|
+
}
|
|
305
|
+
if (authorization) {
|
|
306
|
+
headers.set(authorization.headerName, authorization.header);
|
|
307
|
+
}
|
|
308
|
+
return headers;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* 强制设置 User-Agent 为当前 Session 的 User-Agent
|
|
312
|
+
* @param {Headers} headers 请求头
|
|
313
|
+
* @param {Electron.Session} targetSession 目标 Session
|
|
314
|
+
* @private
|
|
315
|
+
*/
|
|
316
|
+
forceUserAgent(headers, targetSession) {
|
|
317
|
+
headers.set("user-agent", targetSession.getUserAgent());
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* 构建请求体
|
|
321
|
+
* @param {unknown} body 请求体
|
|
322
|
+
* @returns {string | undefined}
|
|
323
|
+
* @private
|
|
324
|
+
*/
|
|
325
|
+
buildRequestBody(body) {
|
|
326
|
+
if (body === void 0 || body === null) {
|
|
327
|
+
return void 0;
|
|
328
|
+
}
|
|
329
|
+
if (typeof body === "string") {
|
|
330
|
+
return body;
|
|
331
|
+
}
|
|
332
|
+
try {
|
|
333
|
+
return JSON.stringify(body);
|
|
334
|
+
} catch {
|
|
335
|
+
throw new Error("\u8FDC\u7A0B\u670D\u52A1\u8BF7\u6C42\u4F53\u65E0\u6CD5\u5E8F\u5217\u5316\u4E3A JSON");
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* 构建可返回到渲染进程的响应头
|
|
340
|
+
* @param {Headers} headers 远程响应头
|
|
341
|
+
* @returns {Record<string, string>}
|
|
342
|
+
* @private
|
|
343
|
+
*/
|
|
344
|
+
buildResponseHeaders(headers) {
|
|
345
|
+
const result = {};
|
|
346
|
+
for (const [name, value] of headers.entries()) {
|
|
347
|
+
const normalizedName = name.toLowerCase();
|
|
348
|
+
if (["set-cookie", "set-cookie2", "authorization"].includes(normalizedName)) {
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
result[name] = value;
|
|
352
|
+
}
|
|
353
|
+
return result;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* 验证远程服务用户设置
|
|
357
|
+
* @param {XoRemoteService.UserSettings} settings 远程服务用户设置
|
|
358
|
+
* @private
|
|
359
|
+
*/
|
|
360
|
+
validateUserSettings(settings) {
|
|
361
|
+
if (settings.serviceUrl?.trim()) {
|
|
362
|
+
this.validateServiceUrl(settings.serviceUrl);
|
|
363
|
+
}
|
|
364
|
+
if (settings.connectionTimeout !== void 0 && (!Number.isFinite(settings.connectionTimeout) || settings.connectionTimeout < 3e3)) {
|
|
365
|
+
settings.connectionTimeout = 3e3;
|
|
366
|
+
}
|
|
367
|
+
if (settings.retryCount !== void 0 && (!Number.isFinite(settings.retryCount) || settings.retryCount < 1)) {
|
|
368
|
+
settings.retryCount = 1;
|
|
369
|
+
}
|
|
370
|
+
if (settings.retryDelay !== void 0 && (!Number.isFinite(settings.retryDelay) || settings.retryDelay < 3e3)) {
|
|
371
|
+
settings.retryDelay = 3e3;
|
|
372
|
+
}
|
|
373
|
+
if (settings.lowFrequencyProbeInterval !== void 0 && (!Number.isFinite(settings.lowFrequencyProbeInterval) || settings.lowFrequencyProbeInterval < 3e4)) {
|
|
374
|
+
settings.lowFrequencyProbeInterval = 3e4;
|
|
375
|
+
}
|
|
376
|
+
if (settings.heartbeatInterval !== void 0 && (!Number.isFinite(settings.heartbeatInterval) || settings.heartbeatInterval < 5e3)) {
|
|
377
|
+
settings.heartbeatInterval = 5e3;
|
|
378
|
+
}
|
|
379
|
+
if (settings.enabled === true && !settings.serviceUrl?.trim()) {
|
|
380
|
+
throw new Error("\u5FC5\u987B\u914D\u7F6E\u670D\u52A1\u5730\u5740");
|
|
381
|
+
}
|
|
382
|
+
if (!settings.heartbeatPath?.trim()) {
|
|
383
|
+
throw new Error("\u5FC5\u987B\u914D\u7F6E\u5FC3\u8DF3\u63A2\u6D4B\u8DEF\u5F84");
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* 验证服务地址
|
|
388
|
+
* <p>仅支持 http/https,生产环境仅允许 https,且必须是合法地址</p>
|
|
389
|
+
* @param {string} url 服务地址
|
|
390
|
+
* @private
|
|
391
|
+
*/
|
|
392
|
+
validateServiceUrl(url) {
|
|
393
|
+
const trimmed = url.trim();
|
|
394
|
+
const scheme = trimmed.match(/^([a-z][a-z0-9+.-]*):\/\//i)?.[1]?.toLowerCase();
|
|
395
|
+
if (scheme === "http" && !AppMode.isDev()) {
|
|
396
|
+
throw new Error("\u8FDC\u7A0B\u670D\u52A1\u5730\u5740\u534F\u8BAE\u65E0\u6548\uFF0C\u4EC5\u652F\u6301 https");
|
|
397
|
+
}
|
|
398
|
+
if (scheme !== "http" && scheme !== "https") {
|
|
399
|
+
throw new Error(`\u8FDC\u7A0B\u670D\u52A1\u5730\u5740\u534F\u8BAE\u65E0\u6548\uFF0C\u4EC5\u652F\u6301 http/https`);
|
|
400
|
+
}
|
|
401
|
+
try {
|
|
402
|
+
const parsed = new URL(trimmed);
|
|
403
|
+
if (!parsed.hostname) {
|
|
404
|
+
throw new Error();
|
|
405
|
+
}
|
|
406
|
+
} catch {
|
|
407
|
+
throw new Error(`\u8FDC\u7A0B\u670D\u52A1\u5730\u5740\u65E0\u6548`);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* 重新发起探测连接
|
|
412
|
+
* @private
|
|
413
|
+
*/
|
|
414
|
+
reconnect() {
|
|
415
|
+
this.stopConnection();
|
|
416
|
+
const settings = this.getEffectiveSettings();
|
|
417
|
+
if (!settings.enabled) {
|
|
418
|
+
this.updateState({ status: "idle", error: void 0 });
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
void this.connect();
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* 是否启用远程服务
|
|
425
|
+
* @returns {boolean}
|
|
426
|
+
*/
|
|
427
|
+
enabled() {
|
|
428
|
+
return this.getEffectiveSettings().enabled;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* 初始化远程服务模块
|
|
432
|
+
* <p>未启用时不发起连接和心跳;启用但未配置服务地址时报错</p>
|
|
433
|
+
* @returns {boolean}
|
|
434
|
+
*/
|
|
435
|
+
initialize() {
|
|
436
|
+
if (this.initialized) {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
this.initialized = true;
|
|
440
|
+
const settings = this.getEffectiveSettings();
|
|
441
|
+
if (!settings.enabled) {
|
|
442
|
+
this.xoApp.remoteServiceLog.info("\u8FDC\u7A0B\u670D\u52A1\u672A\u542F\u7528\uFF0C\u8DF3\u8FC7\u8FDE\u63A5");
|
|
443
|
+
return false;
|
|
444
|
+
}
|
|
445
|
+
if (!settings.serviceUrl) {
|
|
446
|
+
this.xoApp.remoteServiceLog.warn("\u8FDC\u7A0B\u670D\u52A1\u5DF2\u542F\u7528\uFF0C\u4F46\u672A\u914D\u7F6E\u670D\u52A1\u5730\u5740 serviceUrl");
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
void this.connect();
|
|
450
|
+
return true;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* 确保远程服务已连接
|
|
454
|
+
* <p>未连接时立即执行一次探测;并发调用复用当前探测任务</p>
|
|
455
|
+
* @returns {Promise<void>}
|
|
456
|
+
* @private
|
|
457
|
+
*/
|
|
458
|
+
async ensureConnected() {
|
|
459
|
+
if (this.state.status === "connected") {
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
const connected = await this.probe(true);
|
|
463
|
+
const status = this.getState().status;
|
|
464
|
+
if (connected || status === "connected") {
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
if (status === "disconnected") {
|
|
468
|
+
throw new Error("\u8FDC\u7A0B\u670D\u52A1\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
|
|
469
|
+
}
|
|
470
|
+
if (status === "error") {
|
|
471
|
+
throw new Error("\u8FDC\u7A0B\u670D\u52A1\u8FDE\u63A5\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u670D\u52A1\u8BBE\u7F6E");
|
|
472
|
+
}
|
|
473
|
+
throw new Error("\u8FDC\u7A0B\u670D\u52A1\u672A\u8FDE\u63A5");
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* 发起连接(执行一次连接探测)
|
|
477
|
+
* @returns {Promise<void>}
|
|
478
|
+
*/
|
|
479
|
+
async connect() {
|
|
480
|
+
const settings = this.getEffectiveSettings();
|
|
481
|
+
if (!settings.enabled || !settings.serviceUrl) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
this.sessionId++;
|
|
485
|
+
if (this.probing && this.probeSessionId === this.sessionId) {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
if (this.heartbeatTimer || this.retryTimer || this.lowFrequencyProbeTimer) {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
this.manualStopped = false;
|
|
492
|
+
this.retryCount = 0;
|
|
493
|
+
this.clearTimers();
|
|
494
|
+
await this.probe(true);
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* 执行一次连接探测
|
|
498
|
+
* <p>HTTP 请求服务地址,仅 200 视为服务可达,其他状态码或网络错误视为失败</p>
|
|
499
|
+
* @param {boolean} initial 是否为首次连接探测(true 时状态显示为连接中)
|
|
500
|
+
* @returns {Promise<boolean>} 是否探测成功
|
|
501
|
+
* @private
|
|
502
|
+
*/
|
|
503
|
+
async probe(initial) {
|
|
504
|
+
if (this.manualStopped) {
|
|
505
|
+
return false;
|
|
506
|
+
}
|
|
507
|
+
const session = this.sessionId;
|
|
508
|
+
if (this.probing) {
|
|
509
|
+
if (this.probeSessionId === session && this.probePromise) {
|
|
510
|
+
return await this.probePromise;
|
|
511
|
+
}
|
|
512
|
+
if (this.probePromise) {
|
|
513
|
+
await this.probePromise;
|
|
514
|
+
return await this.probe(initial);
|
|
515
|
+
}
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
this.clearReconnectTimers();
|
|
519
|
+
this.probing = true;
|
|
520
|
+
this.probeSessionId = session;
|
|
521
|
+
const probePromise = this.executeProbe(initial, session);
|
|
522
|
+
this.probePromise = probePromise;
|
|
523
|
+
try {
|
|
524
|
+
return await probePromise;
|
|
525
|
+
} finally {
|
|
526
|
+
if (this.probeSessionId === session && this.probePromise === probePromise) {
|
|
527
|
+
this.probing = false;
|
|
528
|
+
this.probePromise = void 0;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* 执行远程服务探测请求
|
|
534
|
+
* @param {boolean} initial 是否为首次连接探测
|
|
535
|
+
* @param {number} session 当前会话序号
|
|
536
|
+
* @returns {Promise<boolean>} 是否探测成功
|
|
537
|
+
* @private
|
|
538
|
+
*/
|
|
539
|
+
async executeProbe(initial, session) {
|
|
540
|
+
const settings = this.getEffectiveSettings();
|
|
541
|
+
if (!settings.enabled) {
|
|
542
|
+
return false;
|
|
543
|
+
}
|
|
544
|
+
const controller = new AbortController();
|
|
545
|
+
this.abortController = controller;
|
|
546
|
+
const timeout = setTimeout(() => controller.abort(), settings.connectionTimeout);
|
|
547
|
+
try {
|
|
548
|
+
if (initial) {
|
|
549
|
+
this.updateState({ status: "connecting", error: void 0 });
|
|
550
|
+
}
|
|
551
|
+
const headers = new Headers();
|
|
552
|
+
const targetSession = this.electronSession();
|
|
553
|
+
const heartbeatUrl = this.buildHeartbeatUrl(settings);
|
|
554
|
+
this.forceUserAgent(headers, targetSession);
|
|
555
|
+
const response = await targetSession.fetch(heartbeatUrl, {
|
|
556
|
+
headers,
|
|
557
|
+
method: "GET",
|
|
558
|
+
credentials: "omit",
|
|
559
|
+
redirect: "error",
|
|
560
|
+
cache: "no-store",
|
|
561
|
+
signal: controller.signal
|
|
562
|
+
});
|
|
563
|
+
const status = response.status;
|
|
564
|
+
await response.body?.cancel().catch(() => void 0);
|
|
565
|
+
this.xoApp.mainLog.debug("\u53D1\u8D77\u8FDC\u7A0B\u670D\u52A1\u63A2\u6D4B", heartbeatUrl);
|
|
566
|
+
if (session !== this.sessionId) {
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
if (status !== 200) {
|
|
570
|
+
this.onProbeFailure(`\u54CD\u5E94\u5F02\u5E38\uFF08HTTP ${status}\uFF09`);
|
|
571
|
+
return false;
|
|
572
|
+
}
|
|
573
|
+
this.onProbeSuccess();
|
|
574
|
+
return true;
|
|
575
|
+
} catch (error) {
|
|
576
|
+
if (session !== this.sessionId) {
|
|
577
|
+
return false;
|
|
578
|
+
}
|
|
579
|
+
this.onProbeFailure(this.toErrorMessage(error));
|
|
580
|
+
return false;
|
|
581
|
+
} finally {
|
|
582
|
+
if (this.abortController === controller) {
|
|
583
|
+
this.abortController = void 0;
|
|
584
|
+
}
|
|
585
|
+
clearTimeout(timeout);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* 探测成功
|
|
590
|
+
* @private
|
|
591
|
+
*/
|
|
592
|
+
onProbeSuccess() {
|
|
593
|
+
this.retryCount = 0;
|
|
594
|
+
this.clearReconnectTimers();
|
|
595
|
+
this.updateState({ status: "connected", error: void 0, connectedAt: Date.now() });
|
|
596
|
+
this.startHeartbeat();
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* 探测失败
|
|
600
|
+
* @param {string} message 失败原因
|
|
601
|
+
* @private
|
|
602
|
+
*/
|
|
603
|
+
onProbeFailure(message) {
|
|
604
|
+
this.stopHeartbeat();
|
|
605
|
+
if (this.manualStopped) {
|
|
606
|
+
this.updateState({ status: "idle", error: void 0 });
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
const settings = this.getEffectiveSettings();
|
|
610
|
+
if (!settings.enabled) {
|
|
611
|
+
this.updateState({ status: "idle", error: void 0 });
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
if (this.retryCount < settings.retryCount) {
|
|
615
|
+
this.retryCount++;
|
|
616
|
+
this.updateState({ status: "disconnected", error: `\u8FDC\u7A0B\u670D\u52A1 ${message}` });
|
|
617
|
+
this.xoApp.remoteServiceLog.warn(`\u8FDC\u7A0B\u670D\u52A1 ${message}\uFF0C${settings.retryDelay}ms \u540E\u91CD\u8BD5\uFF08${this.retryCount}/${settings.retryCount}\uFF09`);
|
|
618
|
+
this.retryTimer = setTimeout(() => {
|
|
619
|
+
this.retryTimer = void 0;
|
|
620
|
+
void this.probe(true);
|
|
621
|
+
}, settings.retryDelay);
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
const enteringLowFrequencyProbe = this.state.status !== "error";
|
|
625
|
+
this.updateState({ status: "error", error: `\u8FDC\u7A0B\u670D\u52A1 ${message}` });
|
|
626
|
+
if (enteringLowFrequencyProbe) {
|
|
627
|
+
this.xoApp.remoteServiceLog.error(
|
|
628
|
+
`\u8FDC\u7A0B\u670D\u52A1 ${message}\uFF0C\u5DF2\u91CD\u8BD5 ${settings.retryCount} \u6B21\uFF0C\u8FDB\u5165\u4F4E\u9891\u63A2\u6D4B`
|
|
629
|
+
);
|
|
630
|
+
} else {
|
|
631
|
+
this.xoApp.remoteServiceLog.warn(
|
|
632
|
+
`\u8FDC\u7A0B\u670D\u52A1 ${message}\uFF0C${settings.lowFrequencyProbeInterval}ms \u540E\u7EE7\u7EED\u4F4E\u9891\u63A2\u6D4B`
|
|
633
|
+
);
|
|
634
|
+
}
|
|
635
|
+
this.scheduleLowFrequencyProbe(settings.lowFrequencyProbeInterval);
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* 安排下一次低频探测
|
|
639
|
+
* @param {number} interval 探测间隔(毫秒)
|
|
640
|
+
* @private
|
|
641
|
+
*/
|
|
642
|
+
scheduleLowFrequencyProbe(interval) {
|
|
643
|
+
if (this.lowFrequencyProbeTimer) {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
this.lowFrequencyProbeTimer = setTimeout(() => {
|
|
647
|
+
this.lowFrequencyProbeTimer = void 0;
|
|
648
|
+
void this.probe(false);
|
|
649
|
+
}, interval);
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* 转换探测错误信息
|
|
653
|
+
* @param {unknown} error 错误对象
|
|
654
|
+
* @returns {string}
|
|
655
|
+
* @private
|
|
656
|
+
*/
|
|
657
|
+
toErrorMessage(error) {
|
|
658
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
659
|
+
return "\u8FDE\u63A5\u8D85\u65F6";
|
|
660
|
+
}
|
|
661
|
+
return error instanceof Error ? error.message : "\u8FDE\u63A5\u5931\u8D25";
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* 转换远程服务请求错误
|
|
665
|
+
* @param {unknown} error 原始错误
|
|
666
|
+
* @returns {Error}
|
|
667
|
+
* @private
|
|
668
|
+
*/
|
|
669
|
+
toRequestError(error) {
|
|
670
|
+
const value = error && typeof error === "object" ? error : void 0;
|
|
671
|
+
const cause = value?.cause && typeof value.cause === "object" ? value.cause : void 0;
|
|
672
|
+
const name = typeof value?.name === "string" ? value.name : "";
|
|
673
|
+
const message = error instanceof Error ? error.message : typeof value?.message === "string" ? value.message : String(error);
|
|
674
|
+
const causeMessage = typeof cause?.message === "string" ? cause.message : "";
|
|
675
|
+
const code = [value?.code, cause?.code].find((item) => typeof item === "string");
|
|
676
|
+
const diagnostic = [code, message, causeMessage].filter(Boolean).join(" ");
|
|
677
|
+
if (name === "AbortError") {
|
|
678
|
+
return new Error("\u8FDC\u7A0B\u670D\u52A1\u8BF7\u6C42\u8D85\u65F6");
|
|
679
|
+
}
|
|
680
|
+
if (/ECONNREFUSED|ERR_CONNECTION_REFUSED/i.test(diagnostic)) {
|
|
681
|
+
return new Error("\u65E0\u6CD5\u8FDE\u63A5\u8FDC\u7A0B\u670D\u52A1\uFF0C\u8BF7\u68C0\u67E5\u670D\u52A1\u5730\u5740\u6216\u786E\u8BA4\u670D\u52A1\u5DF2\u542F\u52A8");
|
|
682
|
+
}
|
|
683
|
+
if (/ENOTFOUND|EAI_AGAIN|ERR_NAME_NOT_RESOLVED/i.test(diagnostic)) {
|
|
684
|
+
return new Error("\u65E0\u6CD5\u89E3\u6790\u8FDC\u7A0B\u670D\u52A1\u5730\u5740\uFF0C\u8BF7\u68C0\u67E5\u670D\u52A1\u5730\u5740\u6216\u7F51\u7EDC\u8FDE\u63A5");
|
|
685
|
+
}
|
|
686
|
+
if (/ETIMEDOUT|ESOCKETTIMEDOUT|ERR_TIMED_OUT/i.test(diagnostic)) {
|
|
687
|
+
return new Error("\u8FDC\u7A0B\u670D\u52A1\u8BF7\u6C42\u8D85\u65F6");
|
|
688
|
+
}
|
|
689
|
+
if (/ECONNRESET|EPIPE|ERR_CONNECTION_RESET/i.test(diagnostic)) {
|
|
690
|
+
return new Error("\u8FDC\u7A0B\u670D\u52A1\u8FDE\u63A5\u5DF2\u4E2D\u65AD\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
|
|
691
|
+
}
|
|
692
|
+
if (/ERR_CERT_|ERR_SSL_|ERR_TLS_|CERT_HAS_EXPIRED|DEPTH_ZERO_SELF_SIGNED_CERT|UNABLE_TO_VERIFY_LEAF_SIGNATURE/i.test(diagnostic)) {
|
|
693
|
+
return new Error("\u8FDC\u7A0B\u670D\u52A1\u8BC1\u4E66\u9A8C\u8BC1\u5931\u8D25");
|
|
694
|
+
}
|
|
695
|
+
return new Error(message || "\u8FDC\u7A0B\u670D\u52A1\u8BF7\u6C42\u5931\u8D25");
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* 构建心跳请求地址
|
|
699
|
+
* <p>未配置心跳路径时直接请求服务地址</p>
|
|
700
|
+
* @param {XoRemoteService.EffectiveSettings} settings 生效设置
|
|
701
|
+
* @returns {string}
|
|
702
|
+
* @private
|
|
703
|
+
*/
|
|
704
|
+
buildHeartbeatUrl(settings) {
|
|
705
|
+
const path = settings.heartbeatPath?.trim() || "";
|
|
706
|
+
if (!path) {
|
|
707
|
+
return settings.serviceUrl;
|
|
708
|
+
}
|
|
709
|
+
return `${settings.serviceUrl.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* 停止当前连接探测
|
|
713
|
+
* @private
|
|
714
|
+
*/
|
|
715
|
+
stopConnection() {
|
|
716
|
+
this.manualStopped = true;
|
|
717
|
+
this.sessionId++;
|
|
718
|
+
this.clearTimers();
|
|
719
|
+
this.abortController?.abort();
|
|
720
|
+
this.abortController = void 0;
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* 启动心跳
|
|
724
|
+
* <p>按间隔周期探测服务地址,失败时进入断开与重试流程</p>
|
|
725
|
+
* @private
|
|
726
|
+
*/
|
|
727
|
+
startHeartbeat() {
|
|
728
|
+
const settings = this.getEffectiveSettings();
|
|
729
|
+
if (!settings.enabled) {
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
this.stopHeartbeat();
|
|
733
|
+
this.heartbeatTimer = setInterval(() => {
|
|
734
|
+
void this.probe(false);
|
|
735
|
+
}, settings.heartbeatInterval);
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* 停止心跳
|
|
739
|
+
* @private
|
|
740
|
+
*/
|
|
741
|
+
stopHeartbeat() {
|
|
742
|
+
if (this.heartbeatTimer) {
|
|
743
|
+
clearInterval(this.heartbeatTimer);
|
|
744
|
+
this.heartbeatTimer = void 0;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* 获取远程服务状态
|
|
749
|
+
* @returns {XoRemoteService.State}
|
|
750
|
+
*/
|
|
751
|
+
getState() {
|
|
752
|
+
return { ...this.state };
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* 监听主进程远程服务状态
|
|
756
|
+
* @param {XoRemoteService.StateListener} listener 状态监听器
|
|
757
|
+
* @returns {() => void} 移除监听器
|
|
758
|
+
*/
|
|
759
|
+
addStateListener(listener) {
|
|
760
|
+
this.stateListeners.add(listener);
|
|
761
|
+
return () => this.stateListeners.delete(listener);
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* 更新远程服务状态
|
|
765
|
+
* @param {Partial<XoRemoteService.State>} state 状态
|
|
766
|
+
* @protected
|
|
767
|
+
*/
|
|
768
|
+
updateState(state) {
|
|
769
|
+
this.state = {
|
|
770
|
+
...this.state,
|
|
771
|
+
...state
|
|
772
|
+
};
|
|
773
|
+
for (const listener of this.stateListeners) {
|
|
774
|
+
listener(this.getState());
|
|
775
|
+
}
|
|
776
|
+
this.syncToAllWindows();
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* 通知远程服务状态到全部渲染进程
|
|
780
|
+
*/
|
|
781
|
+
syncToAllWindows() {
|
|
782
|
+
BrowserWindow.getAllWindows().forEach((window) => this.syncToWindow(window));
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* 通知远程服务状态到渲染进程
|
|
786
|
+
* @param {Electron.BrowserWindow} window 窗口
|
|
787
|
+
*/
|
|
788
|
+
syncToWindow(window) {
|
|
789
|
+
if (window.isDestroyed() || window.webContents.isDestroyed()) {
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
window.webContents.send(RemoteServiceChannels.onState, this.getState());
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* 通知远程服务设置到全部渲染进程
|
|
796
|
+
*/
|
|
797
|
+
syncSettingsToAllWindows() {
|
|
798
|
+
BrowserWindow.getAllWindows().forEach((window) => this.syncSettingsToWindow(window));
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* 通知远程服务设置到渲染进程
|
|
802
|
+
* @param {Electron.BrowserWindow} window 窗口
|
|
803
|
+
*/
|
|
804
|
+
syncSettingsToWindow(window) {
|
|
805
|
+
if (window.isDestroyed() || window.webContents.isDestroyed()) {
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
window.webContents.send(RemoteServiceChannels.onSettings, this.getEffectiveSettings());
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* 清理全部定时器
|
|
812
|
+
* @private
|
|
813
|
+
*/
|
|
814
|
+
clearTimers() {
|
|
815
|
+
this.stopHeartbeat();
|
|
816
|
+
this.clearReconnectTimers();
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* 清理快速重试和低频探测定时器
|
|
820
|
+
* @private
|
|
821
|
+
*/
|
|
822
|
+
clearReconnectTimers() {
|
|
823
|
+
if (this.retryTimer) {
|
|
824
|
+
clearTimeout(this.retryTimer);
|
|
825
|
+
this.retryTimer = void 0;
|
|
826
|
+
}
|
|
827
|
+
if (this.lowFrequencyProbeTimer) {
|
|
828
|
+
clearTimeout(this.lowFrequencyProbeTimer);
|
|
829
|
+
this.lowFrequencyProbeTimer = void 0;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
|
|
834
|
+
// src/main/remote-service/remote-service-manager.ts
|
|
835
|
+
var RemoteServiceManager = class extends RemoteServiceManagerAbstract {
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
export {
|
|
839
|
+
RemoteServiceManagerAbstract,
|
|
840
|
+
RemoteServiceManager
|
|
841
|
+
};
|