@rynt/sdk 0.9.53
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 +122 -0
- package/REGISTRIES.md +189 -0
- package/env.d.ts +11 -0
- package/host-shims.d.ts +30 -0
- package/package.json +88 -0
- package/src/extension-marketplace/api-types.ts +141 -0
- package/src/extension-marketplace/client.ts +296 -0
- package/src/extension-marketplace/index.ts +22 -0
- package/src/extension-marketplace/schemas.ts +178 -0
- package/src/extensions/ExtensionRoutePage.vue +17 -0
- package/src/extensions/context.ts +37 -0
- package/src/extensions/disabled-folder.ts +21 -0
- package/src/extensions/extension-expose-map.ts +5 -0
- package/src/extensions/extension-expose.ts +48 -0
- package/src/extensions/graph.ts +67 -0
- package/src/extensions/index.ts +251 -0
- package/src/extensions/invite-handler/types.ts +20 -0
- package/src/extensions/launcher-entities/create-launcher-entity.ts +25 -0
- package/src/extensions/launcher-entities/keys.ts +46 -0
- package/src/extensions/launcher-entities/launcher-entity-components.ts +177 -0
- package/src/extensions/launcher-entities/props-map.ts +69 -0
- package/src/extensions/launcher-entities/registry.ts +32 -0
- package/src/extensions/launcher-models/apis/accounts-contracts.ts +102 -0
- package/src/extensions/launcher-models/apis/launcher-model-apis.ts +553 -0
- package/src/extensions/launcher-models/keys.ts +23 -0
- package/src/extensions/launcher-models/public.ts +9 -0
- package/src/extensions/launcher-models/registry-core.ts +34 -0
- package/src/extensions/manifest-types.ts +22 -0
- package/src/extensions/manifest.ts +46 -0
- package/src/extensions/marketplace-open-key.ts +26 -0
- package/src/extensions/plugin-types.ts +44 -0
- package/src/extensions/plugin.ts +62 -0
- package/src/extensions/registries/bootstrap.ts +11 -0
- package/src/extensions/registries/builtins/account-provider.ts +6 -0
- package/src/extensions/registries/builtins/app-topbar-left-widgets.ts +6 -0
- package/src/extensions/registries/builtins/app-topbar-right-widgets.ts +6 -0
- package/src/extensions/registries/builtins/app-topbar-status-widgets.ts +6 -0
- package/src/extensions/registries/builtins/build-card-actions.ts +6 -0
- package/src/extensions/registries/builtins/build-card-after-meta.ts +6 -0
- package/src/extensions/registries/builtins/build-card-before-media.ts +6 -0
- package/src/extensions/registries/builtins/build-card-before-meta.ts +6 -0
- package/src/extensions/registries/builtins/build-card-footer-actions.ts +6 -0
- package/src/extensions/registries/builtins/build-detail-after-content.ts +6 -0
- package/src/extensions/registries/builtins/build-detail-before-content.ts +6 -0
- package/src/extensions/registries/builtins/build-detail-before-hero.ts +6 -0
- package/src/extensions/registries/builtins/build-detail-header-actions.ts +6 -0
- package/src/extensions/registries/builtins/build-detail-mod-row-actions.ts +6 -0
- package/src/extensions/registries/builtins/build-detail-resourcepack-row-actions.ts +6 -0
- package/src/extensions/registries/builtins/build-detail-right-column-bottom.ts +6 -0
- package/src/extensions/registries/builtins/build-detail-right-column-top.ts +6 -0
- package/src/extensions/registries/builtins/dialog-footer-actions.ts +6 -0
- package/src/extensions/registries/builtins/feed-after-content.ts +6 -0
- package/src/extensions/registries/builtins/feed-before-content.ts +6 -0
- package/src/extensions/registries/builtins/file-editor.ts +19 -0
- package/src/extensions/registries/builtins/friends-after-list.ts +6 -0
- package/src/extensions/registries/builtins/friends-before-list.ts +6 -0
- package/src/extensions/registries/builtins/index.ts +141 -0
- package/src/extensions/registries/builtins/invite-handler.ts +7 -0
- package/src/extensions/registries/builtins/library-after-content.ts +6 -0
- package/src/extensions/registries/builtins/library-before-content.ts +6 -0
- package/src/extensions/registries/builtins/loader.ts +8 -0
- package/src/extensions/registries/builtins/map-card-actions.ts +6 -0
- package/src/extensions/registries/builtins/map-card-after-meta.ts +6 -0
- package/src/extensions/registries/builtins/map-card-before-meta.ts +6 -0
- package/src/extensions/registries/builtins/map-card-footer-actions.ts +6 -0
- package/src/extensions/registries/builtins/map-detail-after-content.ts +6 -0
- package/src/extensions/registries/builtins/map-detail-before-content.ts +6 -0
- package/src/extensions/registries/builtins/map-detail-header-actions.ts +6 -0
- package/src/extensions/registries/builtins/markdown-editor-tiptap-extensions.ts +7 -0
- package/src/extensions/registries/builtins/markdown-editor-toolbar-actions.ts +6 -0
- package/src/extensions/registries/builtins/markdown-renderer-after-content.ts +6 -0
- package/src/extensions/registries/builtins/markdown-renderer-before-content.ts +6 -0
- package/src/extensions/registries/builtins/mod-details-footer-actions.ts +6 -0
- package/src/extensions/registries/builtins/mod-manage-actions.ts +6 -0
- package/src/extensions/registries/builtins/mod-provider.ts +5 -0
- package/src/extensions/registries/builtins/nav.ts +7 -0
- package/src/extensions/registries/builtins/page.ts +13 -0
- package/src/extensions/registries/builtins/projects-after-content.ts +6 -0
- package/src/extensions/registries/builtins/projects-before-content.ts +6 -0
- package/src/extensions/registries/builtins/resourcepack-manage-actions.ts +7 -0
- package/src/extensions/registries/builtins/server-card-actions.ts +6 -0
- package/src/extensions/registries/builtins/server-card-after-meta.ts +6 -0
- package/src/extensions/registries/builtins/server-card-before-meta.ts +6 -0
- package/src/extensions/registries/builtins/server-card-footer-actions.ts +6 -0
- package/src/extensions/registries/builtins/server-detail-after-content.ts +6 -0
- package/src/extensions/registries/builtins/server-detail-before-content.ts +6 -0
- package/src/extensions/registries/builtins/server-detail-header-actions.ts +6 -0
- package/src/extensions/registries/builtins/settings-after-sections.ts +6 -0
- package/src/extensions/registries/builtins/settings-before-sections.ts +6 -0
- package/src/extensions/registries/builtins/settings-section-widgets.ts +6 -0
- package/src/extensions/registries/builtins/shaderpack-manage-actions.ts +7 -0
- package/src/extensions/registries/builtins/shell.ts +5 -0
- package/src/extensions/registries/builtins/sidebar-after-content.ts +6 -0
- package/src/extensions/registries/builtins/sidebar-before-content.ts +6 -0
- package/src/extensions/registries/builtins/sidebar-footer-widgets.ts +6 -0
- package/src/extensions/registries/builtins/sidebar-header-widgets.ts +6 -0
- package/src/extensions/registries/builtins/sidebar.ts +11 -0
- package/src/extensions/registries/builtins/theme.ts +5 -0
- package/src/extensions/registries/builtins/user-card-after-meta.ts +6 -0
- package/src/extensions/registries/builtins/user-card-before-meta.ts +6 -0
- package/src/extensions/registries/builtins/user-menu-actions.ts +6 -0
- package/src/extensions/registries/builtins/user-menu-after-actions.ts +6 -0
- package/src/extensions/registries/builtins/user-menu-before-actions.ts +6 -0
- package/src/extensions/registries/builtins/user-strip.ts +5 -0
- package/src/extensions/registries/clear-extension-ui-registries.ts +15 -0
- package/src/extensions/registries/define-extension-registry.ts +58 -0
- package/src/extensions/registries/extension-host-api.ts +41 -0
- package/src/extensions/registries/extension-registry-api.ts +103 -0
- package/src/extensions/registries/extension-registry-payload-map.ts +9 -0
- package/src/extensions/registries/extension-scope.ts +41 -0
- package/src/extensions/registries/get-registry.ts +23 -0
- package/src/extensions/registries/index.ts +58 -0
- package/src/extensions/registries/manifest-rynt.ts +193 -0
- package/src/extensions/registries/registry-slot.ts +40 -0
- package/src/extensions/registries/registry-value-map.ts +89 -0
- package/src/extensions/registries/store.ts +206 -0
- package/src/extensions/resolve-extensions.ts +245 -0
- package/src/extensions/router-bridge.ts +103 -0
- package/src/extensions/session.ts +6 -0
- package/src/extensions/slug.ts +23 -0
- package/src/extensions/version.ts +147 -0
- package/src/host/extensions-composables.ts +33 -0
- package/src/host/extensions-init.ts +194 -0
- package/src/host/index.ts +11 -0
- package/src/host/launcher-models/index.ts +4 -0
- package/src/index.ts +229 -0
- package/src/minecraft-loader/base-loader.ts +102 -0
- package/src/minecraft-loader/index.ts +11 -0
- package/src/minecraft-loader/loader-registry.ts +72 -0
- package/src/shared/api/assets.ts +112 -0
- package/src/shared/api/auth.ts +283 -0
- package/src/shared/api/builds.ts +647 -0
- package/src/shared/api/config.ts +19 -0
- package/src/shared/api/download-stats.ts +103 -0
- package/src/shared/api/downloads.ts +36 -0
- package/src/shared/api/entity-authorship.ts +60 -0
- package/src/shared/api/events.ts +393 -0
- package/src/shared/api/friends.ts +140 -0
- package/src/shared/api/graphql.ts +87 -0
- package/src/shared/api/index.ts +23 -0
- package/src/shared/api/invites.ts +262 -0
- package/src/shared/api/library.ts +44 -0
- package/src/shared/api/maps.ts +385 -0
- package/src/shared/api/notify-websocket.ts +140 -0
- package/src/shared/api/posts.ts +357 -0
- package/src/shared/api/projectServers.ts +379 -0
- package/src/shared/api/serverMembers.ts +173 -0
- package/src/shared/api/users.ts +294 -0
- package/src/shared/composables/buildEditor/useBuildEditor.ts +66 -0
- package/src/shared/composables/buildManifest/buildManifest.ts +447 -0
- package/src/shared/composables/filesEditor/filesEditor.ts +346 -0
- package/src/shared/composables/index.ts +10 -0
- package/src/shared/composables/modsEditor/modsEditor.ts +1678 -0
- package/src/shared/composables/registrySlot/registry-slot-utils.ts +25 -0
- package/src/shared/composables/registrySlot/useRegistrySlotMissing.ts +35 -0
- package/src/shared/composables/resourcePacksEditor/resourcePacksEditor.ts +448 -0
- package/src/shared/composables/shaderPacksEditor/shaderPacksEditor.ts +395 -0
- package/src/shared/composables/useSkinRender.ts +70 -0
- package/src/shared/composables/useZlDeepLink.ts +178 -0
- package/src/shared/definitions/defineGraphCache.ts +216 -0
- package/src/shared/definitions/defineStore.ts +32 -0
- package/src/shared/definitions/index.ts +2 -0
- package/src/shared/minecraft-types/build-manifest.ts +611 -0
- package/src/shared/minecraft-types/index.ts +3 -0
- package/src/shared/minecraft-types/launcher-versions.ts +32 -0
- package/src/shared/minecraft-types/minecraft-launcher-types.ts +276 -0
- package/src/shared/mocks/index.ts +1 -0
- package/src/shared/mocks/navigation.ts +17 -0
- package/src/shared/mods/http.ts +45 -0
- package/src/shared/mods/index.ts +5 -0
- package/src/shared/mods/marketplace-editor-search.ts +266 -0
- package/src/shared/mods/marketplace-search-utils.ts +42 -0
- package/src/shared/mods/mod-marketplace-registry.ts +66 -0
- package/src/shared/mods/mod-marketplace-types.ts +28 -0
- package/src/shared/mods/providers/curseforge.ts +464 -0
- package/src/shared/mods/providers/index.ts +8 -0
- package/src/shared/mods/providers/modrinth.ts +402 -0
- package/src/shared/mods/resolve-mods-provider-loader-ids.ts +77 -0
- package/src/shared/mods/types.ts +76 -0
- package/src/shared/styles/index.css +713 -0
- package/src/shared/themes/index.ts +23 -0
- package/src/shared/themes/theme-tokens-black.json +126 -0
- package/src/shared/themes/theme-tokens-classic.json +126 -0
- package/src/shared/themes/theme-tokens-pink.json +126 -0
- package/src/shared/themes/theme-tokens.json +126 -0
- package/src/shared/themes/types.ts +85 -0
- package/src/shared/types/API_DOCUMENTATION.md +422 -0
- package/src/shared/types/account.ts +40 -0
- package/src/shared/types/build.ts +8 -0
- package/src/shared/types/entities.ts +181 -0
- package/src/shared/types/index.ts +6 -0
- package/src/shared/types/invite-payloads.ts +60 -0
- package/src/shared/types/navigation.ts +16 -0
- package/src/shared/types/running-build.ts +51 -0
- package/src/shared/types/serverMember.ts +17 -0
- package/src/shared/types/user.ts +55 -0
- package/src/shared/ui/base/Avatar.vue +262 -0
- package/src/shared/ui/base/Badge.vue +47 -0
- package/src/shared/ui/base/Button.vue +78 -0
- package/src/shared/ui/base/Divider.vue +42 -0
- package/src/shared/ui/base/Icon.vue +597 -0
- package/src/shared/ui/base/StatusIndicator.vue +44 -0
- package/src/shared/ui/base/index.ts +7 -0
- package/src/shared/ui/cards/InviteCard.vue +47 -0
- package/src/shared/ui/cards/index.ts +2 -0
- package/src/shared/ui/dialog/Dialog.vue +71 -0
- package/src/shared/ui/dialog/DialogContent.vue +31 -0
- package/src/shared/ui/dialog/DialogFooter.vue +14 -0
- package/src/shared/ui/dialog/DialogHeader.vue +41 -0
- package/src/shared/ui/dialog/index.ts +5 -0
- package/src/shared/ui/editors/AttachmentImagesEditor.vue +133 -0
- package/src/shared/ui/editors/ContentAttachmentsDisplay.vue +76 -0
- package/src/shared/ui/editors/MarkdownEditor.vue +956 -0
- package/src/shared/ui/editors/MarkdownRenderer.vue +299 -0
- package/src/shared/ui/editors/RichContentImageViewer.vue +85 -0
- package/src/shared/ui/editors/SocialPostMediaZone.vue +320 -0
- package/src/shared/ui/editors/index.ts +6 -0
- package/src/shared/ui/editors/markdown-editor-gallery.ts +234 -0
- package/src/shared/ui/editors/markdown-editor-image.ts +178 -0
- package/src/shared/ui/form/Checkbox.vue +38 -0
- package/src/shared/ui/form/FormField.vue +30 -0
- package/src/shared/ui/form/FormGrid.vue +38 -0
- package/src/shared/ui/form/ImageEditor.vue +598 -0
- package/src/shared/ui/form/Input.vue +72 -0
- package/src/shared/ui/form/Range.vue +65 -0
- package/src/shared/ui/form/Select.vue +76 -0
- package/src/shared/ui/form/Switch.vue +38 -0
- package/src/shared/ui/form/Textarea.vue +144 -0
- package/src/shared/ui/form/index.ts +9 -0
- package/src/shared/ui/index.ts +9 -0
- package/src/shared/ui/layout/BusyOverlay.vue +31 -0
- package/src/shared/ui/layout/Callout.vue +44 -0
- package/src/shared/ui/layout/Card.vue +38 -0
- package/src/shared/ui/layout/Container.vue +36 -0
- package/src/shared/ui/layout/EmptyState.vue +99 -0
- package/src/shared/ui/layout/EntityMediaRow.vue +54 -0
- package/src/shared/ui/layout/FilterResultsLayout.vue +22 -0
- package/src/shared/ui/layout/FloatingPanel.vue +37 -0
- package/src/shared/ui/layout/FullscreenDimmer.vue +11 -0
- package/src/shared/ui/layout/Grid.vue +40 -0
- package/src/shared/ui/layout/Inline.vue +59 -0
- package/src/shared/ui/layout/LoadingState.vue +39 -0
- package/src/shared/ui/layout/MediaBox.vue +47 -0
- package/src/shared/ui/layout/OverlayPanel.vue +28 -0
- package/src/shared/ui/layout/OverlayWaitPanel.vue +22 -0
- package/src/shared/ui/layout/PageSection.vue +43 -0
- package/src/shared/ui/layout/PageToolbar.vue +29 -0
- package/src/shared/ui/layout/Panel.vue +39 -0
- package/src/shared/ui/layout/ProgressBar.vue +49 -0
- package/src/shared/ui/layout/Section.vue +30 -0
- package/src/shared/ui/layout/SegmentedControl.vue +43 -0
- package/src/shared/ui/layout/SelectableCard.vue +46 -0
- package/src/shared/ui/layout/SelectableRow.vue +41 -0
- package/src/shared/ui/layout/Skeleton.vue +25 -0
- package/src/shared/ui/layout/SkeletonAvatar.vue +30 -0
- package/src/shared/ui/layout/SkeletonEntityCard.vue +20 -0
- package/src/shared/ui/layout/SkeletonFeedPost.vue +22 -0
- package/src/shared/ui/layout/SkeletonGrid.vue +18 -0
- package/src/shared/ui/layout/SkeletonListRow.vue +31 -0
- package/src/shared/ui/layout/SkeletonText.vue +25 -0
- package/src/shared/ui/layout/Stack.vue +42 -0
- package/src/shared/ui/layout/StateBlock.vue +44 -0
- package/src/shared/ui/layout/TwoPaneLayout.vue +35 -0
- package/src/shared/ui/layout/VirtualList.vue +160 -0
- package/src/shared/ui/layout/index.ts +35 -0
- package/src/shared/ui/layout/skeletonSurfaceStyles.ts +24 -0
- package/src/shared/ui/navigation/NavItem.vue +139 -0
- package/src/shared/ui/navigation/Tab.vue +61 -0
- package/src/shared/ui/navigation/Tabs.vue +37 -0
- package/src/shared/ui/navigation/index.ts +4 -0
- package/src/shared/ui/primitives/Action.vue +19 -0
- package/src/shared/ui/primitives/Block.vue +28 -0
- package/src/shared/ui/primitives/CanvasView.vue +19 -0
- package/src/shared/ui/primitives/Control.vue +24 -0
- package/src/shared/ui/primitives/ControlSelect.vue +19 -0
- package/src/shared/ui/primitives/ControlTextarea.vue +17 -0
- package/src/shared/ui/primitives/FieldLabel.vue +19 -0
- package/src/shared/ui/primitives/Form.vue +19 -0
- package/src/shared/ui/primitives/Heading.vue +29 -0
- package/src/shared/ui/primitives/Image.vue +17 -0
- package/src/shared/ui/primitives/LineBreak.vue +3 -0
- package/src/shared/ui/primitives/Link.vue +19 -0
- package/src/shared/ui/primitives/List.vue +28 -0
- package/src/shared/ui/primitives/ListItem.vue +19 -0
- package/src/shared/ui/primitives/OptionItem.vue +19 -0
- package/src/shared/ui/primitives/Text.vue +28 -0
- package/src/shared/ui/primitives/VideoView.vue +19 -0
- package/src/shared/ui/primitives/index.ts +19 -0
- package/src/shared/ui/primitives/resolveElement.ts +25 -0
- package/src/shared/ui/special/AngularAccent.vue +106 -0
- package/src/shared/ui/special/ExtensionRegistrySlotButton.vue +143 -0
- package/src/shared/ui/special/InfoRow.vue +39 -0
- package/src/shared/ui/special/LogViewer.vue +53 -0
- package/src/shared/ui/special/PageHeader.vue +23 -0
- package/src/shared/ui/special/RegistrySlotMissingCallout.vue +48 -0
- package/src/shared/ui/special/WelcomeCard.vue +32 -0
- package/src/shared/ui/special/index.ts +9 -0
- package/src/shared/utils/app-paths.ts +50 -0
- package/src/shared/utils/attachments.ts +16 -0
- package/src/shared/utils/autostart.ts +213 -0
- package/src/shared/utils/build-files.ts +439 -0
- package/src/shared/utils/build-manifest-init.ts +176 -0
- package/src/shared/utils/cloudinary.ts +67 -0
- package/src/shared/utils/cn.ts +7 -0
- package/src/shared/utils/download-stats-week.ts +165 -0
- package/src/shared/utils/entity-api-to-cache.ts +84 -0
- package/src/shared/utils/entity-build-from-api.ts +1 -0
- package/src/shared/utils/entity-display.ts +27 -0
- package/src/shared/utils/entity-map-from-api.ts +1 -0
- package/src/shared/utils/file-hash.ts +65 -0
- package/src/shared/utils/formatSize.ts +5 -0
- package/src/shared/utils/formatTime.ts +157 -0
- package/src/shared/utils/getAccountSkinRender.ts +32 -0
- package/src/shared/utils/index.ts +34 -0
- package/src/shared/utils/local-mods.ts +678 -0
- package/src/shared/utils/local-settings.ts +217 -0
- package/src/shared/utils/member-join-stats.ts +35 -0
- package/src/shared/utils/platform.ts +86 -0
- package/src/shared/utils/play-host-slug.ts +92 -0
- package/src/shared/utils/rich-content.ts +294 -0
- package/src/shared/utils/safeRequest.ts +23 -0
- package/src/shared/utils/semver.ts +81 -0
- package/src/shared/utils/serverPermissions.ts +155 -0
- package/src/shared/utils/skin-render-cache.ts +372 -0
- package/src/shared/utils/stripMarkdown.ts +45 -0
- package/src/shared/utils/transliterate.ts +74 -0
- package/src/shared/utils/updateAccountSkinRender.ts +64 -0
- package/src/shared/utils/updater.ts +218 -0
- package/src/shared/utils/uploadImage.ts +195 -0
- package/src/shared/utils/user-status.ts +9 -0
- package/src/tiptap/index.ts +7 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BuildVersionManifest,
|
|
3
|
+
Mod,
|
|
4
|
+
ResourcePack,
|
|
5
|
+
ShaderPack,
|
|
6
|
+
} from '../minecraft-types/build-manifest';
|
|
7
|
+
|
|
8
|
+
// Проверка на наличие Node.js окружения (NW.js)
|
|
9
|
+
const isNodeEnv = typeof window !== 'undefined' && (window as any).nw;
|
|
10
|
+
|
|
11
|
+
// Динамическая загрузка Node.js модулей
|
|
12
|
+
let fs: any;
|
|
13
|
+
let path: any;
|
|
14
|
+
let os: any;
|
|
15
|
+
|
|
16
|
+
if (isNodeEnv) {
|
|
17
|
+
try {
|
|
18
|
+
const nw = (window as any).nw;
|
|
19
|
+
fs = nw.require('fs');
|
|
20
|
+
path = nw.require('path');
|
|
21
|
+
os = nw.require('os');
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error('Не удалось загрузить Node.js модули:', error);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Получить путь к директории приложения в зависимости от ОС
|
|
29
|
+
*/
|
|
30
|
+
function getAppDataPath(): string | null {
|
|
31
|
+
if (!isNodeEnv || !path || !os) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const platform = process.platform;
|
|
37
|
+
const homeDir = os.homedir();
|
|
38
|
+
|
|
39
|
+
switch (platform) {
|
|
40
|
+
case 'win32':
|
|
41
|
+
// Windows: %APPDATA%\.zaklauncher
|
|
42
|
+
return path.join(
|
|
43
|
+
process.env.APPDATA || path.join(homeDir, 'AppData', 'Roaming'),
|
|
44
|
+
'.zaklauncher',
|
|
45
|
+
);
|
|
46
|
+
case 'darwin':
|
|
47
|
+
// macOS: ~/Library/Application Support/.zaklauncher
|
|
48
|
+
return path.join(
|
|
49
|
+
homeDir,
|
|
50
|
+
'Library',
|
|
51
|
+
'Application Support',
|
|
52
|
+
'.zaklauncher',
|
|
53
|
+
);
|
|
54
|
+
default:
|
|
55
|
+
// Linux и другие: ~/.local/share/.zaklauncher
|
|
56
|
+
return path.join(
|
|
57
|
+
process.env.XDG_DATA_HOME || path.join(homeDir, '.local', 'share'),
|
|
58
|
+
'.zaklauncher',
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error('Ошибка при получении пути к директории приложения:', error);
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Получить путь к директории с версиями Minecraft
|
|
69
|
+
*/
|
|
70
|
+
function getVersionsPath(): string | null {
|
|
71
|
+
if (!path) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const appDataPath = getAppDataPath();
|
|
76
|
+
if (!appDataPath) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return path.join(appDataPath, 'versions');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Получить путь к скрытой директории с версиями (.versions)
|
|
85
|
+
*/
|
|
86
|
+
function getHiddenVersionsPath(): string | null {
|
|
87
|
+
if (!path) return null;
|
|
88
|
+
const appDataPath = getAppDataPath();
|
|
89
|
+
if (!appDataPath) return null;
|
|
90
|
+
return path.join(appDataPath, '.versions');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Получить путь к директории конкретной версии/билда
|
|
95
|
+
*/
|
|
96
|
+
function getBuildPath(buildId: string): string | null {
|
|
97
|
+
if (!path) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const versionsPath = getVersionsPath();
|
|
102
|
+
if (!versionsPath) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return path.join(versionsPath, buildId);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Получить путь к директории сборки
|
|
111
|
+
*/
|
|
112
|
+
export function getBuildDirectory(buildId: string): string | null {
|
|
113
|
+
if (!isNodeEnv || !path) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
return getBuildPath(buildId);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error('Ошибка при получении пути к директории сборки:', error);
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Получить путь к директории сборки в .versions (скачанные сборки)
|
|
127
|
+
*/
|
|
128
|
+
export function getHiddenBuildDirectory(buildId: string): string | null {
|
|
129
|
+
if (!isNodeEnv || !path) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
const hiddenVersionsPath = getHiddenVersionsPath();
|
|
135
|
+
if (!hiddenVersionsPath) return null;
|
|
136
|
+
return path.join(hiddenVersionsPath, buildId);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
console.error(
|
|
139
|
+
'Ошибка при получении пути к скрытой директории сборки:',
|
|
140
|
+
error,
|
|
141
|
+
);
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Проверить, отключен ли файл (имеет расширение .disabled)
|
|
148
|
+
*/
|
|
149
|
+
export function isFileDisabled(filePath: string): boolean {
|
|
150
|
+
if (!path) return false;
|
|
151
|
+
return filePath.endsWith('.disabled');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Получить имя файла без расширения .disabled
|
|
156
|
+
*/
|
|
157
|
+
export function getFileNameWithoutDisabled(filePath: string): string {
|
|
158
|
+
if (!path) return filePath;
|
|
159
|
+
if (filePath.endsWith('.disabled')) {
|
|
160
|
+
return filePath.slice(0, -9); // Remove '.disabled'
|
|
161
|
+
}
|
|
162
|
+
return filePath;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Переименовать файл, добавив или убрав расширение .disabled
|
|
167
|
+
*/
|
|
168
|
+
export function toggleFileDisabled(
|
|
169
|
+
filePath: string,
|
|
170
|
+
disabled: boolean,
|
|
171
|
+
): string {
|
|
172
|
+
if (!path) return filePath;
|
|
173
|
+
|
|
174
|
+
const baseName = getFileNameWithoutDisabled(filePath);
|
|
175
|
+
if (disabled) {
|
|
176
|
+
return `${baseName}.disabled`;
|
|
177
|
+
} else {
|
|
178
|
+
return baseName;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Сканировать локальные моды из директории mods/
|
|
184
|
+
*/
|
|
185
|
+
export function scanLocalMods(
|
|
186
|
+
buildId: string,
|
|
187
|
+
originalManifest: BuildVersionManifest | null,
|
|
188
|
+
): Mod[] {
|
|
189
|
+
if (!isNodeEnv || !fs || !path) return [];
|
|
190
|
+
|
|
191
|
+
const buildDir = getBuildDirectory(buildId);
|
|
192
|
+
if (!buildDir) return [];
|
|
193
|
+
|
|
194
|
+
const modsDir = path.join(buildDir, 'mods');
|
|
195
|
+
if (!fs.existsSync(modsDir)) return [];
|
|
196
|
+
|
|
197
|
+
// Получаем список файлов модов из исходного манифеста
|
|
198
|
+
// Учитываем, что файлы могут иметь .disabled в конце
|
|
199
|
+
const manifestModFiles = new Set<string>();
|
|
200
|
+
if (originalManifest?.mods) {
|
|
201
|
+
for (const mod of originalManifest.mods) {
|
|
202
|
+
for (const file of mod.files || []) {
|
|
203
|
+
// Получаем имя файла из path или filename
|
|
204
|
+
const fileName = path.basename(file.path || file.filename || '');
|
|
205
|
+
const fileNameWithoutDisabled = getFileNameWithoutDisabled(fileName);
|
|
206
|
+
|
|
207
|
+
// Добавляем оба варианта: с .disabled и без
|
|
208
|
+
manifestModFiles.add(fileName);
|
|
209
|
+
manifestModFiles.add(fileNameWithoutDisabled);
|
|
210
|
+
manifestModFiles.add(`${fileNameWithoutDisabled}.disabled`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const localMods: Mod[] = [];
|
|
216
|
+
|
|
217
|
+
try {
|
|
218
|
+
const files = fs.readdirSync(modsDir, { withFileTypes: true });
|
|
219
|
+
|
|
220
|
+
for (const file of files) {
|
|
221
|
+
if (!file.isFile()) continue;
|
|
222
|
+
|
|
223
|
+
const fileName = file.name;
|
|
224
|
+
const fileNameWithoutDisabled = getFileNameWithoutDisabled(fileName);
|
|
225
|
+
|
|
226
|
+
// Пропускаем файлы, которые уже есть в манифесте
|
|
227
|
+
if (
|
|
228
|
+
manifestModFiles.has(fileName) ||
|
|
229
|
+
manifestModFiles.has(fileNameWithoutDisabled)
|
|
230
|
+
) {
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Пропускаем файлы, которые не являются модами (не .jar)
|
|
235
|
+
if (!fileNameWithoutDisabled.toLowerCase().endsWith('.jar')) {
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const filePath = path.join(modsDir, fileName);
|
|
240
|
+
const stats = fs.statSync(filePath);
|
|
241
|
+
const isDisabled = isFileDisabled(fileName);
|
|
242
|
+
|
|
243
|
+
// Создаем локальный мод
|
|
244
|
+
const localMod: Mod = {
|
|
245
|
+
source: 'direct',
|
|
246
|
+
id: `local-${fileNameWithoutDisabled}`,
|
|
247
|
+
name: fileNameWithoutDisabled.replace(/\.jar$/i, ''),
|
|
248
|
+
projectSlug: fileNameWithoutDisabled
|
|
249
|
+
.replace(/\.jar$/i, '')
|
|
250
|
+
.toLowerCase()
|
|
251
|
+
.replace(/[^a-z0-9]/g, '-'),
|
|
252
|
+
version: 'local',
|
|
253
|
+
constraints: {
|
|
254
|
+
minecraft: originalManifest?._meta?.manifest?.minecraftVersion || '',
|
|
255
|
+
loader: originalManifest?._meta?.manifest?.loader || 'vanilla',
|
|
256
|
+
},
|
|
257
|
+
files: [
|
|
258
|
+
{
|
|
259
|
+
type: 'primary',
|
|
260
|
+
filename: fileNameWithoutDisabled,
|
|
261
|
+
path: `mods/${fileNameWithoutDisabled}`,
|
|
262
|
+
size: stats.size,
|
|
263
|
+
hashes: {
|
|
264
|
+
sha1: '', // Локальные моды не имеют SHA1
|
|
265
|
+
},
|
|
266
|
+
urls: [],
|
|
267
|
+
side: 'both',
|
|
268
|
+
},
|
|
269
|
+
],
|
|
270
|
+
disabled: isDisabled,
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
localMods.push(localMod);
|
|
274
|
+
}
|
|
275
|
+
} catch (error) {
|
|
276
|
+
console.error('Ошибка при сканировании локальных модов:', error);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return localMods;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Сканировать локальные ресурспаки из директории resourcepacks/
|
|
284
|
+
*/
|
|
285
|
+
export function scanLocalResourcePacks(
|
|
286
|
+
buildId: string,
|
|
287
|
+
originalManifest: BuildVersionManifest | null,
|
|
288
|
+
): ResourcePack[] {
|
|
289
|
+
if (!isNodeEnv || !fs || !path) return [];
|
|
290
|
+
|
|
291
|
+
const buildDir = getBuildDirectory(buildId);
|
|
292
|
+
if (!buildDir) return [];
|
|
293
|
+
|
|
294
|
+
const resourcePacksDir = path.join(buildDir, 'resourcepacks');
|
|
295
|
+
if (!fs.existsSync(resourcePacksDir)) return [];
|
|
296
|
+
|
|
297
|
+
// Получаем список файлов ресурспаков из исходного манифеста
|
|
298
|
+
// Учитываем, что файлы могут иметь .disabled в конце
|
|
299
|
+
const manifestRpFiles = new Set<string>();
|
|
300
|
+
if (originalManifest?.resourcePacks) {
|
|
301
|
+
for (const rp of originalManifest.resourcePacks) {
|
|
302
|
+
for (const file of rp.files || []) {
|
|
303
|
+
// Получаем имя файла из path или filename
|
|
304
|
+
const fileName = path.basename(file.path || file.filename || '');
|
|
305
|
+
const fileNameWithoutDisabled = getFileNameWithoutDisabled(fileName);
|
|
306
|
+
|
|
307
|
+
// Добавляем оба варианта: с .disabled и без
|
|
308
|
+
manifestRpFiles.add(fileName);
|
|
309
|
+
manifestRpFiles.add(fileNameWithoutDisabled);
|
|
310
|
+
manifestRpFiles.add(`${fileNameWithoutDisabled}.disabled`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const localResourcePacks: ResourcePack[] = [];
|
|
316
|
+
|
|
317
|
+
try {
|
|
318
|
+
const files = fs.readdirSync(resourcePacksDir, { withFileTypes: true });
|
|
319
|
+
|
|
320
|
+
for (const file of files) {
|
|
321
|
+
if (!file.isFile()) continue;
|
|
322
|
+
|
|
323
|
+
const fileName = file.name;
|
|
324
|
+
const fileNameWithoutDisabled = getFileNameWithoutDisabled(fileName);
|
|
325
|
+
|
|
326
|
+
// Пропускаем файлы, которые уже есть в исходном манифесте
|
|
327
|
+
// Проверяем оба варианта: с .disabled и без
|
|
328
|
+
if (
|
|
329
|
+
manifestRpFiles.has(fileName) ||
|
|
330
|
+
manifestRpFiles.has(fileNameWithoutDisabled)
|
|
331
|
+
) {
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Пропускаем файлы, которые не являются ресурспаками (не .zip)
|
|
336
|
+
if (!fileNameWithoutDisabled.toLowerCase().endsWith('.zip')) {
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const filePath = path.join(resourcePacksDir, fileName);
|
|
341
|
+
const stats = fs.statSync(filePath);
|
|
342
|
+
const isDisabled = isFileDisabled(fileName);
|
|
343
|
+
|
|
344
|
+
// Создаем локальный ресурспак
|
|
345
|
+
const localRp: ResourcePack = {
|
|
346
|
+
source: 'direct',
|
|
347
|
+
id: `local-${fileNameWithoutDisabled}`,
|
|
348
|
+
name: fileNameWithoutDisabled.replace(/\.zip$/i, ''),
|
|
349
|
+
projectSlug: fileNameWithoutDisabled
|
|
350
|
+
.replace(/\.zip$/i, '')
|
|
351
|
+
.toLowerCase()
|
|
352
|
+
.replace(/[^a-z0-9]/g, '-'),
|
|
353
|
+
version: 'local',
|
|
354
|
+
constraints: {
|
|
355
|
+
minecraft: originalManifest?._meta?.manifest?.minecraftVersion || '',
|
|
356
|
+
},
|
|
357
|
+
files: [
|
|
358
|
+
{
|
|
359
|
+
filename: fileNameWithoutDisabled,
|
|
360
|
+
path: `resourcepacks/${fileNameWithoutDisabled}`,
|
|
361
|
+
size: stats.size,
|
|
362
|
+
hashes: {
|
|
363
|
+
sha1: '', // Локальные ресурспаки не имеют SHA1
|
|
364
|
+
},
|
|
365
|
+
urls: [],
|
|
366
|
+
},
|
|
367
|
+
],
|
|
368
|
+
disabled: isDisabled,
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
localResourcePacks.push(localRp);
|
|
372
|
+
}
|
|
373
|
+
} catch (error) {
|
|
374
|
+
console.error('Ошибка при сканировании локальных ресурспаков:', error);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
return localResourcePacks;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Переключить состояние disabled для мода/ресурспака
|
|
382
|
+
*/
|
|
383
|
+
export function toggleModDisabled(
|
|
384
|
+
buildId: string,
|
|
385
|
+
mod: Mod,
|
|
386
|
+
disabled: boolean,
|
|
387
|
+
): boolean {
|
|
388
|
+
if (!isNodeEnv || !fs || !path) return false;
|
|
389
|
+
|
|
390
|
+
const buildDir = getBuildDirectory(buildId);
|
|
391
|
+
if (!buildDir) return false;
|
|
392
|
+
|
|
393
|
+
if (mod.files.length === 0) return false;
|
|
394
|
+
|
|
395
|
+
const file = mod.files[0];
|
|
396
|
+
const modsDir = path.join(buildDir, 'mods');
|
|
397
|
+
const currentPath = path.join(modsDir, file.filename);
|
|
398
|
+
const disabledPath = path.join(modsDir, `${file.filename}.disabled`);
|
|
399
|
+
|
|
400
|
+
try {
|
|
401
|
+
if (disabled) {
|
|
402
|
+
// Отключаем: переименовываем в .disabled
|
|
403
|
+
if (fs.existsSync(currentPath)) {
|
|
404
|
+
fs.renameSync(currentPath, disabledPath);
|
|
405
|
+
}
|
|
406
|
+
} else {
|
|
407
|
+
// Включаем: переименовываем из .disabled в обычное имя
|
|
408
|
+
if (fs.existsSync(disabledPath)) {
|
|
409
|
+
fs.renameSync(disabledPath, currentPath);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return true;
|
|
413
|
+
} catch (error) {
|
|
414
|
+
console.error('Ошибка при переключении состояния мода:', error);
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Переключить состояние disabled для ресурспака
|
|
421
|
+
*/
|
|
422
|
+
export function toggleResourcePackDisabled(
|
|
423
|
+
buildId: string,
|
|
424
|
+
resourcePack: ResourcePack,
|
|
425
|
+
disabled: boolean,
|
|
426
|
+
): boolean {
|
|
427
|
+
if (!isNodeEnv || !fs || !path) return false;
|
|
428
|
+
|
|
429
|
+
const buildDir = getBuildDirectory(buildId);
|
|
430
|
+
if (!buildDir) return false;
|
|
431
|
+
|
|
432
|
+
if (resourcePack.files.length === 0) return false;
|
|
433
|
+
|
|
434
|
+
const file = resourcePack.files[0];
|
|
435
|
+
const resourcePacksDir = path.join(buildDir, 'resourcepacks');
|
|
436
|
+
const currentPath = path.join(resourcePacksDir, file.filename);
|
|
437
|
+
const disabledPath = path.join(resourcePacksDir, `${file.filename}.disabled`);
|
|
438
|
+
|
|
439
|
+
try {
|
|
440
|
+
if (disabled) {
|
|
441
|
+
// Отключаем: переименовываем в .disabled
|
|
442
|
+
if (fs.existsSync(currentPath)) {
|
|
443
|
+
fs.renameSync(currentPath, disabledPath);
|
|
444
|
+
}
|
|
445
|
+
} else {
|
|
446
|
+
// Включаем: переименовываем из .disabled в обычное имя
|
|
447
|
+
if (fs.existsSync(disabledPath)) {
|
|
448
|
+
fs.renameSync(disabledPath, currentPath);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return true;
|
|
452
|
+
} catch (error) {
|
|
453
|
+
console.error('Ошибка при переключении состояния ресурспака:', error);
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Удалить локальный мод/ресурспак (удалить файл)
|
|
460
|
+
*/
|
|
461
|
+
export function deleteLocalMod(buildId: string, mod: Mod): boolean {
|
|
462
|
+
if (!isNodeEnv || !fs || !path) return false;
|
|
463
|
+
|
|
464
|
+
const buildDir = getBuildDirectory(buildId);
|
|
465
|
+
if (!buildDir) return false;
|
|
466
|
+
|
|
467
|
+
if (mod.files.length === 0) return false;
|
|
468
|
+
|
|
469
|
+
const file = mod.files[0];
|
|
470
|
+
const modsDir = path.join(buildDir, 'mods');
|
|
471
|
+
const filePath = path.join(modsDir, file.filename);
|
|
472
|
+
const disabledPath = path.join(modsDir, `${file.filename}.disabled`);
|
|
473
|
+
|
|
474
|
+
try {
|
|
475
|
+
if (fs.existsSync(filePath)) {
|
|
476
|
+
fs.unlinkSync(filePath);
|
|
477
|
+
}
|
|
478
|
+
if (fs.existsSync(disabledPath)) {
|
|
479
|
+
fs.unlinkSync(disabledPath);
|
|
480
|
+
}
|
|
481
|
+
return true;
|
|
482
|
+
} catch (error) {
|
|
483
|
+
console.error('Ошибка при удалении локального мода:', error);
|
|
484
|
+
return false;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Сканировать локальные шейдеры из директории shaderpacks/
|
|
490
|
+
*/
|
|
491
|
+
export function scanLocalShaderPacks(
|
|
492
|
+
buildId: string,
|
|
493
|
+
originalManifest: BuildVersionManifest | null,
|
|
494
|
+
): ShaderPack[] {
|
|
495
|
+
if (!isNodeEnv || !fs || !path) return [];
|
|
496
|
+
|
|
497
|
+
const buildDir = getBuildDirectory(buildId);
|
|
498
|
+
if (!buildDir) return [];
|
|
499
|
+
|
|
500
|
+
const shaderPacksDir = path.join(buildDir, 'shaderpacks');
|
|
501
|
+
if (!fs.existsSync(shaderPacksDir)) return [];
|
|
502
|
+
|
|
503
|
+
const manifestSpFiles = new Set<string>();
|
|
504
|
+
if (originalManifest?.shaderPacks) {
|
|
505
|
+
for (const sp of originalManifest.shaderPacks) {
|
|
506
|
+
for (const file of sp.files || []) {
|
|
507
|
+
const fileName = path.basename(file.path || file.filename || '');
|
|
508
|
+
const fileNameWithoutDisabled = getFileNameWithoutDisabled(fileName);
|
|
509
|
+
manifestSpFiles.add(fileName);
|
|
510
|
+
manifestSpFiles.add(fileNameWithoutDisabled);
|
|
511
|
+
manifestSpFiles.add(`${fileNameWithoutDisabled}.disabled`);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
const localShaderPacks: ShaderPack[] = [];
|
|
517
|
+
|
|
518
|
+
try {
|
|
519
|
+
const files = fs.readdirSync(shaderPacksDir, { withFileTypes: true });
|
|
520
|
+
|
|
521
|
+
for (const file of files) {
|
|
522
|
+
if (!file.isFile()) continue;
|
|
523
|
+
|
|
524
|
+
const fileName = file.name;
|
|
525
|
+
const fileNameWithoutDisabled = getFileNameWithoutDisabled(fileName);
|
|
526
|
+
|
|
527
|
+
if (
|
|
528
|
+
manifestSpFiles.has(fileName) ||
|
|
529
|
+
manifestSpFiles.has(fileNameWithoutDisabled)
|
|
530
|
+
) {
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
if (!fileNameWithoutDisabled.toLowerCase().endsWith('.zip')) {
|
|
535
|
+
continue;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
const filePath = path.join(shaderPacksDir, fileName);
|
|
539
|
+
const stats = fs.statSync(filePath);
|
|
540
|
+
const isDisabled = isFileDisabled(fileName);
|
|
541
|
+
|
|
542
|
+
const localSp: ShaderPack = {
|
|
543
|
+
source: 'direct',
|
|
544
|
+
id: `local-${fileNameWithoutDisabled}`,
|
|
545
|
+
name: fileNameWithoutDisabled.replace(/\.zip$/i, ''),
|
|
546
|
+
projectSlug: fileNameWithoutDisabled
|
|
547
|
+
.replace(/\.zip$/i, '')
|
|
548
|
+
.toLowerCase()
|
|
549
|
+
.replace(/[^a-z0-9]/g, '-'),
|
|
550
|
+
version: 'local',
|
|
551
|
+
constraints: {
|
|
552
|
+
minecraft: originalManifest?._meta?.manifest?.minecraftVersion || '',
|
|
553
|
+
},
|
|
554
|
+
files: [
|
|
555
|
+
{
|
|
556
|
+
filename: fileNameWithoutDisabled,
|
|
557
|
+
path: `shaderpacks/${fileNameWithoutDisabled}`,
|
|
558
|
+
size: stats.size,
|
|
559
|
+
hashes: {
|
|
560
|
+
sha1: '',
|
|
561
|
+
},
|
|
562
|
+
urls: [],
|
|
563
|
+
},
|
|
564
|
+
],
|
|
565
|
+
disabled: isDisabled,
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
localShaderPacks.push(localSp);
|
|
569
|
+
}
|
|
570
|
+
} catch (error) {
|
|
571
|
+
console.error('Ошибка при сканировании локальных шейдеров:', error);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
return localShaderPacks;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Переключить состояние disabled для шейдера
|
|
579
|
+
*/
|
|
580
|
+
export function toggleShaderPackDisabled(
|
|
581
|
+
buildId: string,
|
|
582
|
+
shaderPack: ShaderPack,
|
|
583
|
+
disabled: boolean,
|
|
584
|
+
): boolean {
|
|
585
|
+
if (!isNodeEnv || !fs || !path) return false;
|
|
586
|
+
|
|
587
|
+
const buildDir = getBuildDirectory(buildId);
|
|
588
|
+
if (!buildDir) return false;
|
|
589
|
+
|
|
590
|
+
if (shaderPack.files.length === 0) return false;
|
|
591
|
+
|
|
592
|
+
const file = shaderPack.files[0];
|
|
593
|
+
const shaderPacksDir = path.join(buildDir, 'shaderpacks');
|
|
594
|
+
const currentPath = path.join(shaderPacksDir, file.filename);
|
|
595
|
+
const disabledPath = path.join(shaderPacksDir, `${file.filename}.disabled`);
|
|
596
|
+
|
|
597
|
+
try {
|
|
598
|
+
if (disabled) {
|
|
599
|
+
if (fs.existsSync(currentPath)) {
|
|
600
|
+
fs.renameSync(currentPath, disabledPath);
|
|
601
|
+
}
|
|
602
|
+
} else {
|
|
603
|
+
if (fs.existsSync(disabledPath)) {
|
|
604
|
+
fs.renameSync(disabledPath, currentPath);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
return true;
|
|
608
|
+
} catch (error) {
|
|
609
|
+
console.error('Ошибка при переключении состояния шейдера:', error);
|
|
610
|
+
return false;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Удалить локальный шейдер (удалить файл)
|
|
616
|
+
*/
|
|
617
|
+
export function deleteLocalShaderPack(
|
|
618
|
+
buildId: string,
|
|
619
|
+
shaderPack: ShaderPack,
|
|
620
|
+
): boolean {
|
|
621
|
+
if (!isNodeEnv || !fs || !path) return false;
|
|
622
|
+
|
|
623
|
+
const buildDir = getBuildDirectory(buildId);
|
|
624
|
+
if (!buildDir) return false;
|
|
625
|
+
|
|
626
|
+
if (shaderPack.files.length === 0) return false;
|
|
627
|
+
|
|
628
|
+
const file = shaderPack.files[0];
|
|
629
|
+
const shaderPacksDir = path.join(buildDir, 'shaderpacks');
|
|
630
|
+
const filePath = path.join(shaderPacksDir, file.filename);
|
|
631
|
+
const disabledPath = path.join(shaderPacksDir, `${file.filename}.disabled`);
|
|
632
|
+
|
|
633
|
+
try {
|
|
634
|
+
if (fs.existsSync(filePath)) {
|
|
635
|
+
fs.unlinkSync(filePath);
|
|
636
|
+
}
|
|
637
|
+
if (fs.existsSync(disabledPath)) {
|
|
638
|
+
fs.unlinkSync(disabledPath);
|
|
639
|
+
}
|
|
640
|
+
return true;
|
|
641
|
+
} catch (error) {
|
|
642
|
+
console.error('Ошибка при удалении локального шейдера:', error);
|
|
643
|
+
return false;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* Удалить локальный ресурспак (удалить файл)
|
|
649
|
+
*/
|
|
650
|
+
export function deleteLocalResourcePack(
|
|
651
|
+
buildId: string,
|
|
652
|
+
resourcePack: ResourcePack,
|
|
653
|
+
): boolean {
|
|
654
|
+
if (!isNodeEnv || !fs || !path) return false;
|
|
655
|
+
|
|
656
|
+
const buildDir = getBuildDirectory(buildId);
|
|
657
|
+
if (!buildDir) return false;
|
|
658
|
+
|
|
659
|
+
if (resourcePack.files.length === 0) return false;
|
|
660
|
+
|
|
661
|
+
const file = resourcePack.files[0];
|
|
662
|
+
const resourcePacksDir = path.join(buildDir, 'resourcepacks');
|
|
663
|
+
const filePath = path.join(resourcePacksDir, file.filename);
|
|
664
|
+
const disabledPath = path.join(resourcePacksDir, `${file.filename}.disabled`);
|
|
665
|
+
|
|
666
|
+
try {
|
|
667
|
+
if (fs.existsSync(filePath)) {
|
|
668
|
+
fs.unlinkSync(filePath);
|
|
669
|
+
}
|
|
670
|
+
if (fs.existsSync(disabledPath)) {
|
|
671
|
+
fs.unlinkSync(disabledPath);
|
|
672
|
+
}
|
|
673
|
+
return true;
|
|
674
|
+
} catch (error) {
|
|
675
|
+
console.error('Ошибка при удалении локального ресурспака:', error);
|
|
676
|
+
return false;
|
|
677
|
+
}
|
|
678
|
+
}
|